删除部分边框
问题描述:
我有一个小部件,其中不能将包裹在另一个div中。删除部分边框
我的问题是如何从标题/标题栏中删除边框,但仍然保留在DIV的其余部分?下面的例子。
仅向.body添加边框是不可行的,因为如果最终用户向小部件div的底部/顶部添加了填充部分,则会导致事件中断。
<div class="widget">
<div class="header">Header Title</div>
<div class="body">My Content</div>
</div>
.widget {
height: 100px;
width: 130px;
border: 3px solid blue;
position: absolute;
overflow: hidden;
}
.header {
width: 100%;
min-height: 24px;
max-height: 24px;
display: block;
background-color: grey;
color: white;
}
.body {
width: 100%;
height: calc(100% - 24px);
}
答
.widget {
height: 100px;
width: 130px;
border: 3px solid blue;
position: absolute;
}
.header {
width: 100%;
min-height: 24px;
max-height: 24px;
display: block;
background-color: grey;
color: white;
margin: -3px;
padding: 3px;
}
.body {
width: 100%;
height: calc(100% - 24px);
}
答
可以实现通过CSS2的结果而已,只是添加边框的body
,而不是整个widget
:
.widget {
width: 130px;
position: absolute;
padding: 25px;
}
.header {
width: 100%;
min-height: 24px;
max-height: 24px;
display: block;
background-color: grey;
color: white;
padding: 3px;
position: absolute;
top: 0;
left: 0;
right: 0;
}
.body {
width: 100%;
height: 100px;
border: 3px solid blue;
border-top-width: 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 30px;
}
+0
重新阅读这个问题。 – 2014-10-06 22:52:55
+0
@White Oooops先生,我的错。我已经更新了我的答案......(注意我已添加到“小部件”的“padding”。 – dashtinejad 2014-10-07 04:44:47
http://jsfiddle.net/botwfngv/1/ – Cheery 2014-10-03 18:12:20
谢谢! – 2014-10-03 18:13:35
不幸的是,'overflow:hidden;'应该被移除,否则你不能覆盖父子的边界。 – Cheery 2014-10-03 18:15:10