将 span 的内容包装在 li 中,使其保留在自己的列中

发布于 2024-09-04 05:41:03 字数 330 浏览 2 评论 0原文

我有一个列表,其中的每个 li 都有这样的结构:

<li>
  <img class="yes" src="...">
  <img class="no"  src="...">
  <span class="a">...</span>
  <span class="b">...</span>
</li>

现在如果类 b 的内容很长,它将环绕图像。我不希望它包裹在图像下方,我希望它保留在自己的列中。如果有办法做到这一点,请告诉我,因为使用表格来做到这一点是错误的。 谢谢! 尼玛

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

<li>
  <img class="yes" src="...">
  <img class="no"  src="...">
  <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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素食主义者 2024-09-11 05:41:03

你可以做几件事;

1) 在图像底部添加填充,以占据跨度文本通常会流入的空间。快速且简单,但对于动态页面来说并不现实。

2)在跨度周围包裹一个div。然后将 div 向右浮动,左边距与图像列的大小相同。然后,这将创建一个不会围绕图像流动的 div 容器。

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.

愚人国度 2024-09-11 05:41:03

谢谢对来,

我添加了div。这是实现这一目的的 css:

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

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

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文