Baz*_*zzz 56
是的,但它不是div,它是一个fieldset
<fieldset>
  <legend>AAA</legend>
</fieldset>
CSS:
fieldset {
    border: 1px solid #000;
}
Jas*_*aro 44
你可以做这样的事情,你margin在h1(或者你正在使用的任何标题)上设置负数
div{
    height:100px;
    width:100px;
    border:2px solid black;
}
h1{
    width:30px;
    margin-top:-10px;
    margin-left:5px;
    background:white;
}
注意:您需要设置background,以及一个width上h1
编辑
为了使它能够隐藏div,你可以像这样使用一些jQuery
$('a').click(function(){
    var a = $('h1').detach();
    $('div').hide();
    $(a).prependTo('body');    
});
(你需要修改......)
示例#2: http ://jsfiddle.net/ZgEMM/4/
我知道派对有点晚了,不过我觉得答案可以用更多的调查/输入来解决.我设法在不使用fieldset标签的情况下创建了这种情况 - 这无论如何都是错误的,好像我不是一个形式然后那不是我应该做的事情.
/* Styles go here */
#info-block section {
    border: 2px solid black;
}
.file-marker > div {
    padding: 0 3px;
    height: 100px;
    margin-top: -0.8em;
    
}
.box-title {
    background: white none repeat scroll 0 0;
    display: inline-block;
    padding: 0 2px;
    margin-left: 8em;
}<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="/style.css">
    <script src="index.js"></script>
  </head>
  <body>
    <aside id="info-block">
      <section class="file-marker">
              <div>
                  <div class="box-title">
                      Audit Trail
                  </div>
                  <div class="box-contents">
                      <div id="audit-trail">
                      </div>
                  </div>
              </div>
      </section>
    </aside>
  </body>
</html>这可以在这个插件中查看:
这实现了以下目标:
没有使用fieldsets.
如果CSS只使用一些填充来创建效果,则使用最少.
使用"em"margin top创建字体相对标题.
使用display inline-block来实现文本周围的自然宽度.
无论如何,我希望有助于未来的风格,你永远不会知道.
.box{
    background-image: url("https://i.stack.imgur.com/N39wV.jpg");
    width: 350px;
    padding: 10px;
}
/*begin first box*/
.first{
    width: 300px;
    height: 100px;
    margin: 10px;
    border-width: 0 2px 0 2px;
    border-color: #333;
    border-style: solid;
    position: relative;
}
.first span {
    position: absolute;
    display: flex;
    right: 0;
    left: 0;
    align-items: center;
}
.first .foo{
    top: -8px;
}
.first .bar{
    bottom: -8.5px;
}
.first span:before{
    margin-right: 15px;
}
.first span:after {
    margin-left: 15px;
}
.first span:before , .first span:after {
    content: ' ';
    height: 2px;
    background: #333;
    display: block;
    width: 50%;
}
/*begin second box*/
.second{
    width: 300px;
    height: 100px;
    margin: 10px;
    border-width: 2px 0 2px 0;
    border-color: #333;
    border-style: solid;
    position: relative;
}
.second span {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.second .foo{
    left: -15px;
}
.second .bar{
    right: -15.5px;
}
.second span:before{
    margin-bottom: 15px;
}
.second span:after {
    margin-top: 15px;
}
.second span:before , .second span:after {
    content: ' ';
    width: 2px;
    background: #333;
    display: block;
    height: 50%;
}<div class="box">
    <div class="first">
        <span class="foo">FOO</span>
        <span class="bar">BAR</span>
    </div>
   <br>
    <div class="second">
        <span class="foo">FOO</span>
        <span class="bar">BAR</span>
    </div>
</div><fieldset>
  <legend> YOUR TITLE </legend>
  
  
  <p>
  Lorem ipsum dolor sit amet, est et illum reformidans, at lorem propriae mei. Qui legere commodo mediocritatem no. Diam consetetur.
  </p>
</fieldset>