A
A
Alekosh Akhosh2021-08-30 03:59:14
Layout
Alekosh Akhosh, 2021-08-30 03:59:14

Is it possible to add a line at half the height of the text?

Good morning, is it possible to add a line with ?
612c2c9bc0e76745634770.png

.text {
  position: relative;
}

.text-decor {
  position: absolute;
  Width: 180px;
  Height: 8px;
  top: 10px;
  left: 0;
  background-color: red;
  opacity: 0.6;
}

<div class="text">
<p> another text </p>
</div>

<div class="text-decor"> </div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Zolin, 2021-08-30
@Akhosh

<p class="text-decor">another text</p>
<span class="text-decor">another text</span>

p, span {
  line-height: 1.25;
}

.text-decor {
  position: relative;
}

.text-decor::after {
  content: '';
  position: absolute;
  width: 100%;
  max-width: 180px;
  height: 50%;
  bottom: 0;
  left: 0;
  background: red;
  opacity: 1;
  z-index: -1;
}

A
Alekosh Akhosh, 2021-08-30
@Akhosh

I centered the text, but the line stays on the left edge due to left: 0; Can it be corrected?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question