I am having difficulty getting 3 images of equal size to float properly. I have set the right and left margins on the center floated image to auto and it still doesn't work. All the panels in my layout are floated left which I revised from tutorials and works ok as they're butted up against each other, but trying to float images when there is more space than necessary, doesn't display as I want: with equal spacing between images Left & Center and Center & Right. My content panel is 534px wide with 10px padding taking up 554px plus a 1px border plus a 5px margin around the outside. The images are all 160px wide and I gave the FloatLeft class a 10px right margin, the FloatRight class a 10px left margin and the FloatCenter an auto margin for both left and right. Both FloatLeft and FloatRight are used on several pages, surrounded by text, which is fine.
Ok, update - I now realise float: center is not possible, DUH!, which is the problem - I'm just a few months into CSS etc.!
Are there any alternatives (other than a table). I could align them all left and make the margin: right attribute 27px (160px x 3 images + 27 + 27 = 534px) but then I'd need to create a new FloatLeft class specifically for these images. Any suggestions on the best method of aligning the images would be much appreciated.
Gary.
The relevant HTML & CSS:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Solar Power Today</title>
<link rel="stylesheet" type="text/css" href="solarpower.css">
</head>
<body>
<div id="wrapper">
...........
<!-- header panel, then horizontal navigation panel then left panel then ... -->
..........
<div id="content">
<!-- main content -->
<h1 id="contentheader">Introduction to Solar Power</h1>
<p>
<img class="FloatLeft" src="images/sunonsolarpanelroof160px.jpg" alt="Sun shining
on roof solar panels" width="160" height="160">
<img class="FloatCenter" src="images/smallwindturbine160px.jpg" alt="Small wind
turbine spinning" width="160" height="160">
<img class="FloatRight" src="images/waveturbine160px.jpg" alt="Wave turbines in
motion" width="160" height="160">
</p>
CSS:
* {padding:0; margin:0; border:0;}
.FloatLeft {
float: left;
margin: 0 10px 10px 0;
}
.FloatRight {
float: right;
margin: 0 0 10px 10px;
}
.FloatCenter {
float: center;
margin: 0 auto 10px auto;
}
#content {
width: 534px;
min-height: 400px;
margin: 0px 5px 5px 0px;
padding: 10px;
float: left;
border: 1px solid black;
display: inline;
}