需要两个 div 才能正确排列

发布于 2024-07-13 15:54:12 字数 639 浏览 5 评论 0原文

这是两个 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 技术交流群。

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

发布评论

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

评论(4

嘿嘿嘿 2024-07-20 15:54:12

.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.

∞琼窗梦回ˉ 2024-07-20 15:54:12

另一种选择(尽管你确实应该给右列一个宽度):

    .col-middle {
        ...
        margin-left: 20%;
    }

编辑:如果你给 .col-middle 一个左边距,则不需要浮动它或给它一个宽度。宽度

Another option (although you really should give the right column a width as well):

    .col-middle {
        ...
        margin-left: 20%;
    }

Edit: If you give .col-middle a left margin, there´s no need to float it or to give it a width

棒棒糖 2024-07-20 15:54:12

添加 a

clear:none;

到您的列 div

和 a

width:80%;

到您的中间列应该使它们能够并排:)

adding a

clear:none;

to both you column divs

and a

width:80%;

to your middle column should enable them to go side by side :)

感情洁癖 2024-07-20 15:54:12

col-middle 采用宽度:100%,因此您必须提供宽度:小于 80%。

您可以做的另一个解决方案是设置宽度:79% 并删除 float:left 并使其显示:table-cell;

.col-middle {
  width: 79%
  height:auto;
  display: table-cell;
  xmargin-top:5px;
  xfont-size:.8em;
  border:1px solid red;
  font-family:arial;
}

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;

.col-middle {
  width: 79%
  height:auto;
  display: table-cell;
  xmargin-top:5px;
  xfont-size:.8em;
  border:1px solid red;
  font-family:arial;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文