在两行之间制作标题

时间:2015-01-06 23:05:08

标签: html css html-heading

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

如何使用任何标题标签制作标题,但我想要标题之间的标题:

HTML:

<h4>Staging Server</h4>

插图:

sample

4 个答案:

答案 0 :(得分:1)

字面意思是谷歌的第一个结果...

&#13;
&#13;
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;
}
&#13;
<p class="subtitle fancy"><span>A fancy subtitle</span></p>
&#13;
&#13;
&#13;

取自here

答案 1 :(得分:1)

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

&#13;
&#13;
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%;
}
&#13;
<h4><span>Staging Server</span></h4>
&#13;
&#13;
&#13;

答案 2 :(得分:1)

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

http://jsfiddle.net/3qcpjgxw/

答案 3 :(得分:0)

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

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

还有一点CSS调整:

hr, h4 {
  display:inline-block;
}

hr {
  width:30%;
}