I've been working on a dropdown menu similar to suckerfish. I've got the dropdown side working now, but I have some images I'm trying to put on either side of the links. Right now I'm using a div the size of the image, then setting the background-image
property to the image I need (so that it can change using the pseudo :hover class).
Here is the CSS That applies:
ul#menu3 li { color: #000000; float: left; /*I've done a little playing around here, doesn't seem to do anything*/ position: relative; /*margin-bottom:-1px;*/ line-height: 31px; width: 10em; padding: none; font-weight: bold; display: block; vertical-align: middle; background-image: url(../../images/dropdown/button-tile.gif); } .imgDivRt { width: 20px; height: 31px; display: inline; float: right; vertical-align: middle; background-image: url(../../images/dropdown/button-right.gif); } .imgDivLt { width: 20px; height: 31px; display: inline; float: left; vertical-align: middle; background-image: url(../../images/dropdown/button-left.gif); }
I was using selectors to save a little on having different classes, but internet explorer doesn't seem to support them :(
Here is my HTML that applies:
<li><div class="imgDivLt"></div>Option 1<div class="imgDivRt"></div> <ul> <li><a href="#"><div class="imgDivLt"></div>Sub 1<div class="imgDivRt"></div></a> <ul> <li><a href="#"><div class="imgDivLt"></div>Sandwich<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sandwich<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sandwich<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sandwich<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sandwich<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sandwich<div class="imgDivRt"></div></a></li> </ul> </li> <li><a href="#"><div class="imgDivLt"></div>Sub 2<div class="imgDivRt"></div></a> <ul> <li><a href="#"><div class="imgDivLt"></div>Sub 1<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 2<div class="imgDivRt"></div></a> </li> <li><a href="#"><div class="imgDivLt"></div>Sub 3<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 4<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 5<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 6<div class="imgDivRt"></div></a></li> </ul> </li> <li><a href="#"><div class="imgDivLt"></div>Sub 3<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 4<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 5<div class="imgDivRt"></div></a></li> <li><a href="#"><div class="imgDivLt"></div>Sub 6<div class="imgDivRt"></div></a></li> </ul> </li> <li><div class="imgDivLt"></div>Option 2<div class="imgDivRt"></div>
I'm not sure if there's a glitch in my code, or if I'm on the wrong track. It works in firefox, safari, and chrome, but not IE or opera, so I'm not sure if they're making up for stupidity or what. Ideally, the second image floats greedily to the right in the containing block. In the problem browsers, it sits the next line down (at the far right at least)
To display multiple div tags in the same line, we can use the float property in CSS styles. The float property takes left, right,none(default value) and inherit as values. The value left indicates the div tag will be made to float on the left and right to float the div tag to the right.
css prevent new line div // You should use a <span> element instead, which is inline. // Although it's bad form, you can add style="display: inline;" to a div.
Use CSS property to set the height and width of div and use display property to place div in side-by-side format. float:left; This property is used for those elements(div) that will float on left side. float:right; This property is used for those elements(div) that will float on right side.
You can make two divs inline this way:
display:inline; float:left;
For me, this worked much better, as it didn't eliminate spacing between floated items:
display:inline-block;
In case that helps anyone else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With