Hi, I set up some images to 'text-align:center;' by putting each image in a div and aligning each of the divs by applying a style to each div seperately. It all seemed to be working fine when I looked at it in IE8. However, now I'm doing some work at home, I have viewed it in later browsers and it doesn't seem to be working at all. I have tried applying css to each table row too, but to no avail. Any idea how I can remedy this please? I have pasted the appropriate scripts below. Thanks.
HTML:
<h2>Who Are We?</h2>
<p> </p>
<table width="681" border="5" bordercolor="#00596B" >
<tr class="tbrow_center_image">
<td width="216" height="176"> <div class="centered_image"> <img src="../images/staff_photos/staff_photo_06.jpg" alt="image description" width="156" height="200"> </div> </td>
<td width="220"><div class="centered_image"> <img src="../images/staff_photos/staff_photo_04.jpg" alt="image description" width="156" height="200"> </div></td>
<td width="223"><div class="centered_image"> <img src="../images/staff_photos/staff_photo_02.jpg" alt="image description" width="156" height="200"> </div></td>
</tr>
</table>
CSS in seperate file:
.centered_image
{
text-align:center;
margin-top:0px;
margin-bottom:0px;
padding:0px;
width:156px;
}
.tbrow_center_image
{
text-align:center;
}
Page 1 of 1
Centering images in table. Using text-align:center on divs to centre/center images.
#2
Posted 08 February 2012 - 11:25 AM
Is there a need for the table? Is the data tabular?
If not then you'd be far better off dropping the table completely and using a normal fluid DIV layout.
If not then you'd be far better off dropping the table completely and using a normal fluid DIV layout.
#3
Posted 08 February 2012 - 01:38 PM
Yes, I suppose it is tabular, I haven't put the whole table contents there, I just copied the first row.
#4
Posted 08 February 2012 - 02:07 PM
have u tried adding class to the image and adjust margin? if all images are of same dimension? or adjust padding of the containing td by adding a class?
#5
Posted 08 February 2012 - 02:19 PM
If you put text align center on the TD with the image it should work, and you can also put margin: 0 auto; on the images, but not sure how that behaves in a table.
However, unless this has multiple (3 or more) columns and is information that belongs in a table in a book you probably would be better off by using CSS. If you have to nest another block-level element inside a table cell you probably aren't using tables semantically.
However, unless this has multiple (3 or more) columns and is information that belongs in a table in a book you probably would be better off by using CSS. If you have to nest another block-level element inside a table cell you probably aren't using tables semantically.
This post has been edited by porkchops: 08 February 2012 - 02:20 PM
- ← Making a div link to previous page
- Website Design and Layout
- Navigation Bar List Formatting Issues →
Share this topic:
Page 1 of 1
Help















