Html 左下边框
想象(或者如果你无法想象,请观看)这段代码:Html 左下边框,html,css,border,Html,Css,Border,想象(或者如果你无法想象,请观看)这段代码: <div class="block"></div> <style> .block { width: 10px; height: 10px; display: block; background-color: red; border: 1px solid #000000; border-bottom: 0; } </style> .街区{ 宽度:10
<div class="block"></div>
<style>
.block {
width: 10px;
height: 10px;
display: block;
background-color: red;
border: 1px solid #000000;
border-bottom: 0;
}
</style>
.街区{
宽度:10px;
高度:10px;
显示:块;
背景色:红色;
边框:1px实心#000000;
边界底部:0;
}
现在看看底线。这是我的问题;我希望左边框和右边框长1倍(因此底部边框是左边框和右边框之间的部分)。有可能做到这一点吗?这是一种方法,因为长方体模型不支持您需要的功能,只使用一个div:
<div class="block"><div></div></div>
这将用1px扩展左右两侧的黑色边框。试试这个:)
如果您有两个容器,一个用于左/右外边框,另一个用于底部内边框,则这是可能的。我已经制作了一个演示 演示:
#边界外{
高度:200px;
宽度:300px;
边框:1px实心#900;
边框底部:无;
填充底部:5px;/*这是底部的间隙*/
}
#里边{
身高:100%;
边框底部:1px实心#900;
}
可以在不通过此策略在HTML中添加任何无关元素的情况下完成:
.block {
position: relative;
width: 10px;
height: 10px;
display: block;
background-color: red;
}
.block:before {
position: absolute;
content: '';
width: 10px;
height: 11px;
top: -1px;
left: -1px;
border: 1px solid #000;
border-bottom: none;
}
pseudo元素:before仅在IE8中受支持,但在所有其他主流浏览器中都可以使用
<style type="text/css">
#borderOutside {
height: 200px;
width: 300px;
border:1px solid #900;
border-bottom: none;
padding-bottom: 5px; /*this is the gap at the bottom*/
}
#borderInside {
height: 100%;
border-bottom: 1px solid #900;
}
</style>
<div id="borderOutside">
<div id="borderInside"><!--Your Content--></div>
</div>
.block {
position: relative;
width: 10px;
height: 10px;
display: block;
background-color: red;
}
.block:before {
position: absolute;
content: '';
width: 10px;
height: 11px;
top: -1px;
left: -1px;
border: 1px solid #000;
border-bottom: none;
}