Okay so i came across an issue that is driving me crazy and I am guessing it is because I am just going about it the wrong way.
I have a nav setup in a normal UL.
With css I set the “li” element to have a bottom border.
The bottom border only extends enough to underline the contents inside the “li” tag.
I tried giving the li tag a width of 100% and a width of auto.
Because certain pages have different links, the UL for the nav is set to automatically size the width based on the dynamic contents inside. So the UL is always the correct width.
But the li is only the width of the content in the li, causing some links to have a wider bottom border. I want all the links in the list to have a bottom border with the width of the ul and not the li.
Should i just nix the ul list, and use divs for each item or am i looking at this all wrong?
How can I set the width of the li to always be the width of the UL?
Thank you in advance for any advice and or comments to show me the right direction to proceed!
Using a list instead of <div>s shouldn’t make any difference. I suspect there may be some other feature on the page or in the stylesheet that is affecting it. Can you post a link to the offending page so we can see everything that’s going on?
The list element will by default be as wide as the parent unless you have done something to change it. have you fro example set the list element to display:inline or perhaps floated it?
If so then the width will shrink wrap the content.
If it’s floated you will need a 100% width (and then of course there would probably be no need for floating).
If the element is display:inline then remove the display:inline.
As Stevie said we’d need to see the page to debug further
Thank you for your replies :). Below is a sample of how I am able to replicate the issue. It is a snippet of the css I am using with a jquery script but the code below is enough to duplicate the issue.
The issue only happens with IE7
If I remove “height: 20px;” from the “.sub ul li” class, it fixes the issue… However I am not sure why it fixes the issue or why height causes the issue in the first place…
On my page I need the height in the “.sub ul li” because that UL is nested inside another “UL” which has a taller “li” height than the one I want to use in “.sub ul li”
Yes this is a bug in IE7 and when you apply the height to the list element you force haslayout on the list element and IE7 (and 6) have a lot of bugs when list items hav a layout.
The only solution is remove the height and use either padding or line-height to make the height you need. You can negate the inherited height and turn off haslayout at the same time by using height:auto.
.sub ul li {
width: auto; /*--Override parent list item--*/
color: #ccc;
padding-left:10px;
padding-right:10px;
display:block;
[B] height:auto;[/B]
}
The only other solution would be to give the parent ul a width etc.
I was unable to get the li items to increase their height with a line-height(no matter what value I used it didn’t change)… but was able to achieve the results with a bottom padding.
However thank you for your replies and assistance :)… always learning something new lol.