gpt4 book ai didi

html - 左/右浮动时如何计算位置

转载 作者:行者123 更新时间:2023-11-28 03:11:04 28 4
gpt4 key购买 nike

在下面的引导网格示例中,它使用 col-sm 和 col-sm-push/pull。col-sm-push 指定了左/右值(偏移量)。

我不太清楚它是如何工作的。

第二个 float 元素来到第一个 float 元素的左侧。

当left/right涉及float时,浏览器如何确定其位置?有没有引用指出?

Here is the example link

<div class="row">
<div class="col-sm-4 col-sm-push-8">.col-sm-4 .col-sm-push-8</div>
<div class="col-sm-8 col-sm-pull-4">.col-sm-8 .col-sm-pull-4</div>

@media (min-width: 768px) .col-sm-pull-4 {
right: 33.33333333%;
}
@media (min-width: 768px) .col-sm-8 {
width: 66.66666667%;
}

最佳答案

首先:W3schools 是一个非常糟糕的文档引用,请尝试 MDN(Mozilla 开发者网络)或 W3C 官方网站 (w3.org) 获取文档。

W3 关于 float 的说法如下(右):

Similar to 'left', except the box is floated to the right, and content flows on the left side of the box, starting at the top.

所以这意味着如果您将第一个元素向右浮动,第二个元素将在左侧有空间并尝试将自己定位在那里。

关于html - 左/右浮动时如何计算位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30485998/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com