Getting width from parent element

Hello, I’m sitting here creating a site with a menu using li, etc I have


<ul>
	<li><a href="#">Home</a></li>
	<li>
		<a href="#">Portfilio</a>
		<ul>
			<li><a href="#">Link 1</a></li>
			<li><a href="#">Link 2</a></li>
			<li><a href="#">Link 3</a></li>
		</ul>
	</li>
	<li><a href="#">Hosting</a></li>
	<li>
		<a href="#">JustSomeOtherStuff</a>
		<ul>
			<li><a href="#">Link 1</a></li>
			<li><a href="#">Link 2</a></li>
			<li><a href="#">Link 3</a></li>
		</ul>
	</li>
	<li><a href="#">About us</a></li>
</ul>

as you know the words have different lengths, and I add some padding in the sides of links on 5px, and then some margin between the li’s so the words isn’t standing together… everything works fine…

I create the dropdown so it works… but the width of the dropdown ul - I can set that to etc 160px and the menu will work… but is there any way in css to get the width from the link without I have specified the link width? and then assign it to the sub-uls?

so etc if we say that <a href=“#”>JustSomeOtherStuff</a> was 300pixel wide, then would the sub-ul to that link be the same…

but the problem is that I don’t know what content that is gonna be in the menu… so it should scale dynamically in width, like etc if we say I changed the text from “JustSomeOtherStuff” to “HelloWorld” then the sub-ul would get same width as “HelloWorld” is in width? so I not should sit changing the CSS all the time?

Best regards,

Lucas Rolff

If you set

ul ul {width:100%;}

that should ensure that each sub-menu is the same width as its daddy.

ur pro! problem solved :stuck_out_tongue: