Ссориться между двумя строчками
Это, вероятно, простой вопрос, но:
Как я могу сделать заголовок, используя любой тег заголовка, но я хочу, чтобы заголовок между строками был таким:
HTML:
<h4>Staging Server</h4>
Иллюстрация:
4 ответа
Решение
Вы могли бы использовать :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>
Буквально первый результат в 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>
Взято отсюда.
<fieldset style="border:none; border-top: 1px solid #999;">
<legend style="text-align:center;"> Staging Server </legend>
</fieldset>
Простой пример может быть таким:
<hr><h4>Staging Server</h4><hr>
И немного CSS-твика:
hr, h4 {
display:inline-block;
}
hr {
width:30%;
}