CSS: установить строку CSS
.banner-bottom h2 {
font-size: 2em;
color: #372568;
position: relative;
padding-bottom: 1em;
text-align: center;
}
.banner-bottom h2:before {
content: '';
position: absolute;
top: 25%;
left: 25%;
background: #372568;
height: 2px;
width: 8%;
}
.banner-bottom h2:after {
content: '';
position: absolute;
top: 25%;
right: 25%;
background: #372568;
height: 2px;
width: 8%;
}
<div class="banner-bottom">
<div class="container">
<h2>Special Promo</h2>
<h2>Promo</h2>
<div>
<div>
Ответы
Ответ 1
Значение display
свойства display
- это хорошо, потому что @Vinothin ответил за вас. Вот еще один трюк, который вы можете использовать.
Использование свойства transform
поможет вам при использовании абсолютной позиции.
.banner-bottom h2 {
font-size: 2em;
color: #372568;
position: relative;
padding-bottom: 1em;
text-align: center;
}
.banner-bottom h2:before {
content: '';
position: absolute;
top: 25%;
transform: translateX(-100%);
/* no left value is required */
background: #372568;
height: 2px;
width: 8%;
}
.banner-bottom h2:after {
content: '';
position: absolute;
top: 25%;
/* no right value is required */
background: #372568;
height: 2px;
width: 8%;
}
<div class="banner-bottom">
<div class="container">
<h2>Special Promo</h2>
<h2>Promo</h2>
</div>
</div>
Ответ 2
Попробуйте следующее:
.banner-bottom h2 {
font-size: 2em;
color: #372568;
padding-bottom: 1em;
text-align: center;
}
.line:before {
content: '';
display: inline-block;
background: #372568;
height: 2px;
width: 8%;
margin: 10px;
}
.line:after {
content: '';
display: inline-block;
background: #372568;
height: 2px;
width: 8%;
margin: 10px;
}
.promo {
display: inline-block;
}
<div class="banner-bottom">
<div class="container">
<h2><span class="line"><span class="promo">Special Promo</span></span></h2>
<h2><span class="line"><span class="promo">Promo</span></span></h2>
<div>
<div>