html - 去除部分边框

标签 html css

我有一个小部件不能包含在另一个 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/

最佳答案

.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/

关于html - 去除部分边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26184366/

相关文章:

html - 如何在同一包含元素中以不同方式内联对齐文本 block ?

html - CSS Flexbox float 元素

javascript - 来自 CSV 的 Google 折线图

html - <custom> 没有功能的 html 标签?

html - 如何使用CSS为输入边框底部着色

html - XSLT:组织用于打印的 html 表格

javascript - 格式化文本中的数字

javascript - 如何使用 CSS 和 javascript 使 HTML 在打印 View 上完美呈现?

html - 为什么 "negative margin and float applied elements"重叠?

css - 如何删除 Div 表之间的空间