在两行之间制作小标题

Making a tittle between two lines

这可能是一个简单的问题但是:

如何使用标题标签制作标题,但我希望标题介于两行之间,如下所示:

HTML :

<h4>Staging Server</h4>

插图:

字面意思是 Google 上的第一个结果...

body
{
  background-color: black;
  color: white;
}
.subtitle {
  margin: 0 0 2em 0;
}
.fancy {
  line-height: 0.5;
  text-align: center;
}
.fancy span {
  display: inline-block;
  position: relative;  
}
.fancy span:before,
.fancy span:after {
  content: "";
  position: absolute;
  height: 5px;
  border-bottom: 1px solid white;
  border-top: 1px solid white;
  top: 0;
  width: 600px;
}
.fancy span:before {
  right: 100%;
  margin-right: 15px;
}
.fancy span:after {
  left: 100%;
  margin-left: 15px;
}
<p class="subtitle fancy"><span>A fancy subtitle</span></p>

摘自 here.

你可以使用 :after:before :伪元素。

h4 span {
  position: relative;
  color: #00C8FF;
  padding: 0 15px;
  margin: 0 80px;
  font-size: 16px;
  font-weight: 100;
}
h4 span:before, h4 span:after {
  content: '';
  position: absolute;
  width: 60%;
  height: 1px;
  transform: translateY(-50%);
  top: 50%;
  background: #6F6F6F;
  left: -60%;
}
h4 span:after {
  left: 100%;
}
<h4><span>Staging Server</span></h4>

<fieldset style="border:none; border-top: 1px solid #999;">
    <legend style="text-align:center;"> Staging Server </legend>
</fieldset>

http://jsfiddle.net/3qcpjgxw/

简单的例子可以是这样的:

<hr><h4>Staging Server</h4><hr>

还有一点 CSS 调整:

hr, h4 {
  display:inline-block;
}

hr {
  width:30%;
}