|
|
#1 |
|
Center aligning linked images with CSS
I would like to center aligned my linked images.
To center align, I would have to use the following properties: Code:
display:block; margin:0 auto; In my case, even if I hover over a white space, my hover properties would come into place due to it being changed to a block element. And this wouldn't work unless I have a fixed image size. Is there a fix for this? To center align images if I have different sizes to cater to? |
|
|
|
0
|
|
|
#2 |
|
Not knowing how your code is currently setup I'll offer a couple solutions. First you could place the image inside a paragraph (or a div):
[HTML]<p class="img"><img src="..." alt="..." /></p> CSS: p.img { text-align: center; }[/HTML] Second way, if you have a bunch of images, make a list out of them. [HTML] <ul class="images"> <li><img src="..." alt="..." /></li> <li><img src="..." alt="..." /></li> <li><img src="..." alt="..." /></li> </ul> CSS: ul.images { margin: 0; padding: 0; list-style: none; } ul.images li { margin: 0; padding: 0; text-align: center; }[/HTML] |
|
|
|
0
|
|
|
#3 |
|
While both methods look like a possible solution I have not yet tried, it would involve a lot of work on my part. I am looking for a solution which automatically center aligns images without me having to edit every single post.
Here's how my structure looks like: Code:
<div class="post-content">
<p><img src="" alt="" /></p>
</div>
|
|
|
|
0
|
|
|
#4 |
|
Well, you could try relative units like percent, and do something like:
Code:
.postcontent p img {
position: absolute;
left: 50%;
}
Code:
.postcontent p img, .postcontent p a:hover img {
display:block;
margin:0 auto;
}
|
|
|
|
0
|
|
|
#5 |
|
The above methods won't work.
1) I am using a fixed width layout, and using absolute will definitely not set things right. 2) Display: block would work perfectly if the image was not linked. In my case, it is. That is why I want the link to change color only when I hover over the image, not when it is over the same block area. Thanks for your suggestion though. Is there anyone who could help me solve this problem? |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| center an iframe with css? | Starhorsepax | Web Design and Development | 8 | Feb 22, 2013 03:51 PM |
| Help with CSS alignment in IE7 | jamarwright | Web Design and Development | 2 | Sep 11, 2009 08:58 AM |
| Flash or CSS - Scrolling image with rollover help | LimeiBook86 | Web Design and Development | 6 | Sep 15, 2008 09:45 AM |
| Leader characters on center aligned text | nicrose | Design and Graphics | 1 | Oct 18, 2007 07:22 PM |
| Need help with css background image | Sammie | Web Design and Development (archive) | 2 | Feb 20, 2005 02:03 AM |
All times are GMT -5. The time now is 01:52 PM.





30GB iPod Video

Linear Mode

