Как сделать hr с градиентами на концах?
<div class="description_ul">
<hr>
<ul>
<li>Number of pages</li>
<li>Academic level</li>
<li>Urgency</li>
</ul>
<hr>
</div>
<style>
.description hr{
width: 210px;
height: 1px;
margin: 0 auto;
display: block;
border: 0;
}
.description hr:after {
content: "";
display: block;
width: 30px;
height: 5px;
}
</style>
Ответы (3 шт):
Автор решения: Armen
→ Ссылка
.root{
width: 50px;
height: 50px;
border: 10px solid black;
border-image:
linear-gradient(
to bottom,
red,
rgba(0, 0, 0, 0)
) 1 100%;
}
Автор решения: De.Minov
→ Ссылка
Я бы использовал для этого псевдоэлемент и градиент.
ul {
width: 150px;
}
ul::after {
content: '';
display: block;
width: 100%;
height: 1px;
background: linear-gradient(to right, transparent, black 25%, black 75%, transparent);
margin-top: 10px;
}
<ul>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
Или элемент отдельно, например <hr>
hr {
display: block;
width: 100%;
height: 1px;
border: 0;
background: linear-gradient(to right, transparent, black 25%, black 75%, transparent);
margin: 10px 0;
}
<div style="width: 150px;">
<ul>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
<hr>
</div>
Автор решения: Денис Степанов
→ Ссылка
Вообще, да через псевдоэлементы. Но можно попробовать border-image.
.test-bottom {
display: inline-block;
width: 200px;
height: 100px;
border-style: solid;
border-image: linear-gradient( to right, rgba(0, 0, 0, 0), red, rgba(0, 0, 0, 0)) 1 / 0 0 4px;
}
.test-top {
display: inline-block;
width: 200px;
height: 100px;
border-style: solid;
border-image: linear-gradient( to right, rgba(0, 0, 0, 0), red, rgba(0, 0, 0, 0)) 1 / 4px 0 0;
}
<div class="test-bottom"></div>
<div class="test-top"></div>