I have a list with two <div>
s in every <li>
and I want to float them one next to the other and I want the <li>
to take the whole availabe space. How do I do it?
<html>
<head>
<title></title>
<style type="text/css">
body {
}
ul {
}
li {
}
.a {
}
.b {
}
</style>
</head>
<body>
<ul>
<li>
<div class="a">
content
</div>
<div class="b">
content
</div>
</li>
</ul>
</body>
</html>
I assume by take the whole space you mean a width of 100%. I would also assume that you do not want styling applied to the list, which is why I have removed it in this example. This is also hack-free. You need not clear anything, so long as your list item has a width and the overflow: hidden property/value pair.
Should do the trick.
Without checking to make sure, this should work
That should do as required from my knowledge of CSS
I see this is an old post but if someone runs into the same issue think about this:
You can use span instead of div
To get a div besides the other or horizontally you have to apply brute force with .css but if you use span it will naturally. Copy and paste the following code in a html and see what I'm talking about:
Also, at least for Microsoft
<li><div></div></li>
won't validate.For the divs, you just need to float left and the li, you want to do a clear. So: