html - 如何将具有 table-cell 显示属性的 html 元素向右推送?

标签 html css

所以这是 fiddle :http://jsfiddle.net/myxgy7xg/3/ 我想将“.toTheRight”推到行的右侧,固定宽度为 200 像素。同时,中间 '.b' 的元素占据了当前行的所有剩余宽度。

代码如下: HTML:

<div class="a">
    haha
</div>

<div class="b">
    classb
</div>

<div class="toTheRight">
    to the right!!!
</div>

CSS:

.a,.b,.toTheRight{
    display:table-cell;
}
.a{
    width:200px;
}
.b{
    width:30%;}
.c{ 
    width:200px;
}

最佳答案

这是您要找的吗?

http://jsfiddle.net/myxgy7xg/4/

我只是将 min-width 属性设置为 a 和 c

.a,.b,.toTheRight{
    display:table-cell;
}
.a{
    width:200px;
    min-width:200px;
}
.b{
    width:70%;}
.c{ 
    width:200px;
    min-width:200px;
}

这迫使他们占用整个 200px;

https://developer.mozilla.org/en-US/docs/Web/CSS/min-width

关于html - 如何将具有 table-cell 显示属性的 html 元素向右推送?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26660548/

相关文章:

html - Margin-top 没有被应用(不工作)

html - 在 Mozilla 上用 margin-right 隐藏滚动条会弄乱内容

html - 为什么文本对齐不会对齐 div 中的文本?

javascript - 缩小粘性导航栏

javascript - 自动 "go back"到上一个 url

javascript - PHP: isset() 不检测 GET 变量

html - 如何给内部div相等的边距?

html - 将绝对 div 定位在内联跨度的边缘

css - 将鼠标悬停在链接上时保持菜单打开

html - 删除 css 绝对位置,同时保持元素内联