删除部分边框

问题描述:

我有一个小部件,其中不能将包裹在另一个div中。删除部分边框

我的问题是如何从标题/标题栏中删除边框,但仍然保留在DIV的其余部分?下面的例子。

仅向.body添加边框是不可行的,因为如果最终用户向小部件div的底部/顶部添加了填充部分,则会导致事件中断。

Image issue

<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); 
} 

http://jsfiddle.net/botwfngv/

+1

http://jsfiddle.net/botwfngv/1/ – Cheery 2014-10-03 18:12:20

+0

谢谢! – 2014-10-03 18:13:35

+0

不幸的是,'overflow:hidden;'应该被移除,否则你不能覆盖父子的边界。 – Cheery 2014-10-03 18:15:10

.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); 
} 

http://jsfiddle.net/botwfngv/2/

+0

只需将“margin”和“padding”更改为“-3px”和“3px”以适应“border”。 +1 – melancia 2014-10-03 18:16:38

+0

@MelanciaUK是的,高分辨率屏幕,看不到细节的小细节))Thanx – Cheery 2014-10-03 18:17:29

+0

加分点,如果你可以找出为什么bootstrap打破这个.. = \ http://jsfiddle.net/botwfngv/3/ – 2014-10-03 19:01:08

可以实现通过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; 
} 

JSFiddle Demo

+0

重新阅读这个问题。 – 2014-10-06 22:52:55

+0

@White Oooops先生,我的错。我已经更新了我的答案......(注意我已添加到“小部件”的“padding”。 – dashtinejad 2014-10-07 04:44:47