How to center a vertical bar in CSS? The strip itself is made:
.vline { border-right: 1px solid white; height: 70px; } If the strip is a block element, and you need to align it in the center of the parent container, in which nothing else lies, then you can:
margin:0 auto; If there is something in the parent container and you don’t want to deal with flex, you can do this:
.container{ position:relative; } .container .vline{ position: absolute; left: 50%; } If you need this bar on top of everything in the center of the screen, you can do this:
.vline{ position:fixed; left:50vw; z-index: 100; } Or specify the question and add more code.
Depending on how the rest of the elements will be located, the answer will change. Add a usage example.
Source: https://ru.stackoverflow.com/questions/603057/
All Articles