- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试将 6 个 iframe 排列成两行,以便每行包含三个 iframe。我想要做的是,每个 iframe 都有边距,但接触它容器的 iframe 的边距应该为零。这是代码:
* {
box-sizing: border-box;
}
.bodycontainer3 {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 10px 0;
padding-bottom: 0;
border: 2px dotted red;
}
.bodycontainer3 iframe {
width: 32%;
margin: 1%;
}
.bodycontainer3 iframe:nth-of-type(1),
.bodycontainer3 iframe:nth-of-type(4) {
margin-left: 0;
}
.bodycontainer3 iframe:nth-of-type(3),
.bodycontainer3 iframe:nth-of-type(6) {
margin-right: 0;
}
<body>
<div class="bodycontainer3">
<iframe src="https://www.youtube.com/embed/Q5911Zy7Jos?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/r2rmtwOFLx0?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/AA_TxwrizzQ?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/OaRCWjp4WFo?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/lwbs1BQr0qI?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
<iframe src="https://www.youtube.com/embed/q3gOHGbppIc?autoplay=0" autoplay="0" allowfullscreen="allowfullscreen"></iframe>
</div>
</body>
现在每个 iframe 的宽度为 32%,所以三个 iframe 占用 32%*3 = 96%
。由于折叠而产生的边距是 1%*2 = 2%
。所以一行的总宽度必须是 96% + 2% = 98%
。
我的问题是剩余的 2%
空间在哪里?利润率没有崩溃吗?
最佳答案
好吧,显然我们在追求真相的过程中存在一些误入歧途的看法。
margin-collapsing 不是我们想要的,它不会发生在这个 demo 中。它也不在 OP 的演示中。
iframe 两侧没有边距的原因是因为 iframe 是内联元素,并且 inline elements, they only respect horizontal margins ,所以这就是为什么 iframe 上下都有空间,而左右没有空间的原因。
我制作了带有注释的屏幕截图。总而言之,您一直在误判像素的实际大小。它们很小。您所期望的是您准确获得的两倍。查看屏幕截图。
当一个元素的垂直边距重叠/接触/共享同一空间等时,会发生边距折叠。另一个元素的垂直边距。发生的情况是,两个边距中较大的一个占主导地位并成为唯一的边距,而较小的边距消失了。示例:
Div A { 边距:50px; }Div B { 边距:20px;
Div A 和 Div B 之间的间距现在为 50px。
请阅读此article
这是一个错误,显然 flexbox 在使用百分比时不支持 flex-items 的填充或边距。 https://bugzilla.mozilla.org/show_bug.cgi?id=958714
ems
。 vw
。html { font: 500 10px/1 Arial; }
并使用 rem
。关于html - margin 不会在 iframe 中崩溃吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36232505/
当我设置 margin-right: 50px;我没有看到任何效果,但是当我替换 margin-right: 50px; 时左边距:50px;或 margin-top: 50px;我确实看到了效果。这
CSS .title{ margin-top: 200px; // does not work! margin-left: 20px; font-weight: bold;
我不知道,但是 li 元素的 margin-top 只有在它大于 h2 元素的 margin-bottom 时才会起作用,我想知道为什么? Test1 Test2 谢谢。 最佳答案 您所描述的听起
我有 2 个 div 的问题 - 两个呈现为 block 的边距均为 15px(顶部 div 有底部边距,底部有顶部),因此我预计两者之间的差距是 30px 而不是 15px,这是正确的假设还是我要疯
我一直以为我了解利润率和负利润率,但显然我不了解!我刚刚开始一个新的设计并且已经遇到了问题。 我有一个 div (hill3Cont) 和另一个嵌套在里面的 div (hill3Hill),这是它们的
我有一系列这样的元素: ... ....... ... ....... h1 上边距为 5px,p 上边距为 10px。但是产生的边距只有 10px。如果我将底部边距增加到 50px,将顶部边距增加
由于 margin-right: auto 和 margin-left: auto 水平居中元素,我希望它们的垂直对应物以相同的方式运行。 但我知道这不会发生,根据 CSS 规范: 10.6.2 In
我在让我的 div 将我的页面向下移动 30 像素/在我的 div 顶部添加边距 30 像素时遇到问题。我的 div 使用 margin auto 在页面中心对齐。 然而,当我尝试添加这行代码时:边距
这个问题在这里已经有了答案: CSS margin terror; Margin adds space outside parent element [duplicate] (7 个答案) 关闭
我有一个 div 在另一个之上。顶部的 div 有 margin-bottom: 10px,底部的 div 有 margin-top: 10px,但两个 div 之间只有 10px 的空间。 实例:h
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 2 年前。 我的 CSS 边距没有按照我想要或期望的方
在此website我正在尝试减少横幅和文本之间ON MOBILE 底部和顶部的边距。 如果您在智能手机和平板电脑上查看,横幅的顶部和底部似乎有一些边距。 这是我的 CSS: .page-id-996
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
这个问题在这里已经有了答案: Why does this CSS margin-top style not work? (14 个答案) 关闭 3 年前。
我是一名优秀的程序员,十分优秀!