需要两个 div 才能正确排列
左列是,我想要在其右侧对齐的 div 是
,这两个 div 都在
.content-body {
padding:10px 15px;
font-size:.8em;
font-family:arial;
overflow:auto;
}
.col-left {
float:left;
position:relative;
overflow:auto;
height:100%;
width:20%;
padding:0 5px 0 0;
}
.col-middle {
width:auto;
height:auto;
float:left;
xmargin-top:5px;
xfont-size:.8em;
border:1px solid red;
font-family:arial;
}
如何让 .col-middle div 正确对齐?
任何帮助表示赞赏。
Here is a screenshot of how both div's lineup.
The left column is , the div that I want to line up to the right of it is
And both those div's are within
.content-body {
padding:10px 15px;
font-size:.8em;
font-family:arial;
overflow:auto;
}
.col-left {
float:left;
position:relative;
overflow:auto;
height:100%;
width:20%;
padding:0 5px 0 0;
}
.col-middle {
width:auto;
height:auto;
float:left;
xmargin-top:5px;
xfont-size:.8em;
border:1px solid red;
font-family:arial;
}
How would I get the .col-middle div to line up properly?
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将 .col-middle 的宽度更改为 80% 或更少,以便两个 div 都可以放入其容器内。
您还可以使.col-middle浮动右。
Change the width of .col-middle to 80% or less so both divs can fit inside their container.
You could also make .col-middle float right.
另一种选择(尽管你确实应该给右列一个宽度):
编辑:如果你给 .col-middle 一个左边距,则不需要浮动它或给它一个宽度。宽度
Another option (although you really should give the right column a width as well):
Edit: If you give .col-middle a left margin, there´s no need to float it or to give it a width
添加 a
到您的列 div
和 a
到您的中间列应该使它们能够并排:)
adding a
to both you column divs
and a
to your middle column should enable them to go side by side :)
col-middle 采用宽度:100%,因此您必须提供宽度:小于 80%。
您可以做的另一个解决方案是设置宽度:79% 并删除 float:left 并使其显示:table-cell;
col-middle is taking the width: 100%, so you have to provide the width: less than 80%.
another solution you can do is make the width:79% and remove the float:left and make it display: table-cell;