Style Half <hr> Unlike the other half
7 answers
For the <hr> you can use the css :before pseudo-element to make different colors (please change the colors and sizes to suit your design):
+13
Sergey Sklyar
source shareYou can use the :before pseudo-element for half hr and use the absolute position.
+4
Nenad vracar
source sharewith flex I would do it very simply and use box-shadow on pseudo so that this answer is different from others;)
+4
G-cyr
source shareYes, the previous pseudo version. But here you can use another way that you easily implement using any css grid:
CSS
.red{ border: 2px solid deeppink; position: relative; top: -1px; } HTML:
<div class="container"> <hr class="red col-sm-6" /><hr class="col-sm-6" /> </div> +4
Rust
source shareYou can do this with: before /: after selectors.
SCS:
hr { overflow:initial; &:after { content:''; width:50%; height:3px; display:block; background:red; top:-2px; position:relative; } } Try playing with this fiddle that I created for you: https://jsfiddle.net/fwzs8uy0/
Personally, I use div instead of HR.
+3
Matt
source shareUse a linear gradient. It can help you.
hr { border: 0; height: 1px; background: linear-gradient(to right, red, yellow); } +2
user8885932
source share