Forum Moderators: not2easy
HTML
<p class="bar">
adam <a href="#" title="Home Page">Home</a><img src="myimage.jpg" width="2" height="31" alt="A description of the picture">
</p>
css:
.bar {
float: left;
width: 950px;
margin-top:20px;
background-image:url(background.jpg');
outline: 1px solid red;
}
.bar img {vertical-align:middle}
this solved the problem but is this the correct way? can anybody explain or direct me some to ready about this problem with images sitting next to text?
<div class="bar">
adam
<img src="images/menu_split.gif" width="2" height="31" />
</div>
<ul class="bar">
<li class="first"><a href="#"><span>Home</span></a></li>
<li><a href="#"><span>About</span></a></li>
<li><a href="#"><span>Blog</span></a></li>
<li class="last"><a href="#"><span>Contact</span></a></li>
</ul>
.bar { /* remove the defaults off the ul so it looks and acts like a plain div */
padding: 0;
margin: 0;
list-style: none;
width: 100%;
height: 31px;
overflow: hidden; /* this to contain the floated child links */
background: #dad;
line-height: 31px; /* this makes the text center vertical, without needing to use padding on the li element but only works if the text will always be on one line */
}
.bar li {
float: left;
height: 100%;
background: #eee url(separator.gif) repeat-y top right;/* background image here e.g repeating down the right hand side to make it look like separator */
padding: 0 10px; /* adjust this to make sure the separator "appears" to be in the middle of your list items */
}
/* either one of the two elements below could be used to hold another image, often both are used for rounded corner, fluid effects */
.bar li a, .bar li span {
display: block;
}
/* use the li classes to target the li, a or span - e.g. to remove the image from a singular list item */
.bar li.last {
background: transparent;
}
/* only the ul, or wrapper div, needs a class or ID as all the elements can be targettted via that */
/* e.g.
.bar li {}
.bar li a {}
.bar li span {}
*/
Upon changing to html 4 the code fell to pieces and there was gaps everyway so just changed backOuch ;) But now you appreciate the relevance of doctype!