Reputation: 1372
In HTML, I'm trying to wrap a ul
tag around an image. I need the right number of li
tags to not overlap the image, no matter how tall or short they are. So far, I can get the content inside of the li
tags to wrap around the image, but can't get the li
s themselves to wrap around the image. Since each li
tag has a bottom border, this isn't quite enough. You can see where I have it right now here:
How do I wrap an unordered list around an image so that even the li tags don't overlap the image?
Upvotes: 1
Views: 8342
Reputation: 12011
How about add overflow:hidden;
to the LI tag:
http://jsfiddle.net/BBmER/153/
Upvotes: 0
Reputation: 21
Give the ul element enough padding from left or right so that it wont overlap your image. For example, if your image is floated left and has 300px width, then your ul element should be:
<ul style="padding-left:300px">
or:
<ul style="padding-left:320px">
if you want some space between them.
Upvotes: 2
Reputation: 65126
I modified your new fiddle a bit, is this what you're looking for?
What I did was I
li
s because it was pushing the second li
under the image andclear: left;
on the li
element just in case you have a long label.It doesn't change the fact that the li
elements overlap the image, but at least the label and description elements are laid out properly.
Upvotes: 1
Reputation: 207881
You can accomplish it with some margin and an opaque image. See an updated jsFiddle.
CSS:
body {
font-family: arial, verdana, sans-serif;
font-size:13px;
}
ul li {
margin-bottom:15px;
border-bottom:1px solid grey;
}
img {
float: right;
padding: 0 0 15px 15px;
opacity: 1;
background: #fff;
margin: 0 0 10px 10;
}
Upvotes: 1