CSS - 任何未设置宽度的跨度取余数

标签 css

如果我喜欢:

<div style="width: 100%">
   <span style="width: 5%">5% Width</span>
   ... (some more here)
   <span>Fill the leftover</span>
   ... (more span with width given)
   <span style="width: 5%">5% Width</span>
</div>

有没有办法让 span(放在列表中的任何位置)可以填充左边的宽度?

最佳答案

您应该使用 table 和 table-cell 的显示属性以这种方式完成:

<div style="width: 100%; display:table;">
   <span style="width: 5%; display:table-cell;">5% Width</span>
     ... (some more here)
   <span style='display:table-cell;'>Fill the leftover</span>
    ... (more span with width given)
   <span style="width: 5%; display:table-cell;">5% Width</span>
</div>

关于CSS - 任何未设置宽度的跨度取余数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23947278/

相关文章:

html - Flexbox 侧边栏阻止主要内容在小屏幕上环绕在侧边栏下

javascript - 在轮播上添加暂停/播放功能

jquery - 尝试设置从右侧滑入的 Jansy-bootstrap offcanvas 菜单

javascript - Select2 多个选择框不起作用

javascript - IE10 : Unable to set any flex style properties via Javascript

html - 显示响应式菜单的更智能方式

javascript - HTML:Base64 图像显示/复制高度错误

css - 使用 twitter bootstrap 3 居中 9 列布局

javascript - 所有标签的一级子元素向左浮动会破坏默认显示值

jquery - 渐进式滑动打开 jquery 移动面板