0

How do I make a vertical line from the top to bottom of my site. That should cover the whole height of my site

I have tried height: 100%;, but they disappear.

 .vertical-hr {
  margin-top: -8px;
  width: 0.1%;
  height: 100%;
  float: right;
  background-color: black;
 }

 <div class="vertical-hr"></div>
scriver
  • 85
  • 8

2 Answers2

1

Put vh instead of %

height: 100vh;

and remove float

try the code snippet

.vertical-hr {
  margin-top: -8px;
  width: 1px;
  height: 100vh;
  position: absolute;
  right: 10px;
  background-color: black;
 }
<div class="vertical-hr"></div>
Abal
  • 309
  • 1
  • 20
PRABHAT SINGH RAJPUT
  • 1,455
  • 1
  • 12
  • 31
0

You can achieve it by using a fixed position. Give it a higher stack order(z-index) so that it always appear in the front.

<style>
    .vertical-hr {
        width: 20px;
        background-color: black;
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        z-index: 9999999999;
    }
</style>
<div class="vertical-hr"></div>