Html 在DIV之间合并边界
给你:Html 在DIV之间合并边界,html,css,Html,Css,给你: <div id="weapons_main"> <div class="col1">.</div> <div class="col1">.</div> <div class="clear"></div> <div>1</div> <div>2</div> </div> 问题马上就显现出来了:红线比应该的要粗,因为浏览器会对
<div id="weapons_main">
<div class="col1">.</div>
<div class="col1">.</div>
<div class="clear"></div>
<div>1</div>
<div>2</div>
</div>
问题马上就显现出来了:红线比应该的要粗,因为浏览器会对它们进行汇总,而不是合并。如何避开它?您可以使用
:最后一个孩子和相邻的同级选择器(+)
对于更高级的示例,您可以使用:n子项
#weapons_main .col1:nth-child(2n) {
border-left: 0;
}
您可以使用:最后一个子项和相邻的同级选择器(+)
对于更高级的示例,您可以使用:n子项
#weapons_main .col1:nth-child(2n) {
border-left: 0;
}
要支持IE8,您需要使用:first child
#weapons_main .col1:nth-child(2n) {
border-left: 0;
}
样本:
#weapons_main div:first-child {
border-bottom: 0;
}
要支持IE8,您需要使用:first child
#weapons_main .col1:nth-child(2n) {
border-left: 0;
}
样本:
#weapons_main div:first-child {
border-bottom: 0;
}
试试这个:
#weapons_main
{
-moz-box-sizing: border-box;
background-color: #FFFFFF;
border: thin solid #869BBF;
border-collapse: collapse;
margin: 0 auto;
padding: 0;
width: 80%;
}
#weapons_main div
{
background-color: #EFF0FB;
border-top: solid 5px red;
border-left: solid 5px red;
border-right: solid 5px red;
border-bottom: none;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
border-collapse: collapse;
}
#weapons_main div:last-child
{
border-bottom: solid 5px red;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
border-collapse: collapse;
}
#weapons_main .col1
{
border-bottom: solid 5px red;
width: 50%;
float: left;
display: inline-block;
margin: 0;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
border-collapse: collapse;
}
链接:
附加:尝试以下操作:
#weapons_main
{
-moz-box-sizing: border-box;
background-color: #FFFFFF;
border: thin solid #869BBF;
border-collapse: collapse;
margin: 0 auto;
padding: 0;
width: 80%;
}
#weapons_main div
{
background-color: #EFF0FB;
border-top: solid 5px red;
border-left: solid 5px red;
border-right: solid 5px red;
border-bottom: none;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
border-collapse: collapse;
}
#weapons_main div:last-child
{
border-bottom: solid 5px red;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
border-collapse: collapse;
}
#weapons_main .col1
{
border-bottom: solid 5px red;
width: 50%;
float: left;
display: inline-block;
margin: 0;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
border-collapse: collapse;
}
链接:
附加:您可以使用以下方法:
display: table;
对于容器和
display: table-row;
对于将保存行内容和
display: table-cell
对于单元格div,您可以使用以下方法:
display: table;
对于容器和
display: table-row;
对于将保存行内容和
display: table-cell
对于单元格div如果我得到了您想要做的,为什么不使用table
s而不是div
s呢?lolololol我刚刚被命令不使用table,而是使用div构造。但有一点很好。如果我明白了你的意思,为什么不使用table
s而不是div
s呢?洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛洛。但好的一点。比边界塌陷:塌陷代码>将开始工作。然后边框折叠:折叠代码>将起作用。