I need implement custom text decoration, see image below:
It is simple to simulate -
row with next styles:
color: red;
border-bottom: 3px dashed; // 3px - just for example, 2.5 also looks fine.
But I can't find out how to implement underline using +
symbols.
Actually, I know that it is possible to have background-image
, but it wouldn't work if text would be long.
I would appreciate any help. Thank you in advance.
UPD: Simple code snippet to play with:
<main>
<h1>Here goes some heading <span class="deleted">and this is deleted</span></h1>
<p>And here goes more text. <span class="added">This was inserted.</span> More text <span class="deleted">This was deleted</span></p>
</main>
You can do this with gradient like below:
.deleted {
background:
repeating-linear-gradient(to right,red 0 4px,transparent 4px 6px)
bottom/100% 2px no-repeat;
}
.added {
background:
repeating-linear-gradient(to right,green 0px 1px,transparent 1px 5px)
bottom 0 left 2px/100% 5px no-repeat,
linear-gradient(green,green) bottom 2px left 0/100% 1px no-repeat;
padding-bottom:4px;
}
<main>
<h1>Here goes some heading <span class="deleted">and this is deleted</span></h1>
<p>And here goes more text. <span class="added">This was inserted.</span> More text <span class="deleted">This was deleted</span></p>
</main>
If you want some spaces between the +
.deleted {
background:
repeating-linear-gradient(to right,red 0 4px,transparent 4px 6px)
bottom/100% 2px no-repeat;
}
.added {
background:
repeating-linear-gradient(to right,green 0 1px,transparent 1px 7px)
bottom 0 left 2px/100% 5px no-repeat,
repeating-linear-gradient(to right,green 0 5px,transparent 5px 7px)
bottom 2px left 0/100% 1px no-repeat;
padding-bottom:4px;
}
<main>
<h1>Here goes some heading <span class="deleted">and this is deleted</span></h1>
<p>And here goes more text. <span class="added">This was inserted.</span> More text <span class="deleted">This was deleted</span></p>
</main>
It will also work with multiline text:
.deleted {
background:
repeating-linear-gradient(to right,red 0 4px,transparent 4px 6px)
bottom/100% 2px no-repeat;
}
.added {
background:
repeating-linear-gradient(to right,green 0 1px,transparent 1px 7px)
bottom 0 left 2px/100% 5px no-repeat,
repeating-linear-gradient(to right,green 0 5px,transparent 5px 7px)
bottom 2px left 0/100% 1px no-repeat;
padding-bottom:4px;
}
<main>
<h1>Here goes some heading <span class="deleted">and this is deleted</span></h1>
<p>And here goes more text. <span class="added">This is long long long long long long long long long long text was inserted.</span> More text <span class="deleted">This was deleted</span></p>
</main>