开发者

wrapping the content of a span inside an li so it stays in its own column

开发者 https://www.devze.com 2023-01-02 16:37 出处:网络
I have a list, each li in it has this structure: <li> <img class=\"yes\" src=\"...\"> <img class=\"no\"src=\"..开发者_如何学JAVA.\">

I have a list, each li in it has this structure:

<li>
  <img class="yes" src="...">
  <img class="no"  src="..开发者_如何学JAVA.">
  <span class="a">...</span>
  <span class="b">...</span>
</li>

now if the content of class b is long, it will wrap around the image. I don't want it to wrap under the image, I want it to stay in its own column. If there is anyway to do this, please let me know as using tables to do it will be just wrong. Thanks! Nima


You can do a couple things;

1) Add padding to the bottom of the image to take the space the span text normally would flow into. Quick and easy, but not realistic for dynamic pages.

2) Wrap a div around the spans. Then float the div right with a left margin the size of the image column. This will then create a div container that will not flow around the image.


Thanks Duilai,

I added the div. Here is the css that did the trick:

.divClass
{
    margin-left:30px;
    text-align:left;
}

.yes, .no
{
    float:left;
    width:15px;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号