Can I make a sidebar stick to the left or right side on my screen in HTML and CSS? (Not a navbar)

Viewed 739

I have two divs.

<div class="sideBarLeft">
...
</div>
<div class="content">
...
</div>

and

div.content {
    background-color: rgba(0, 0, 0, 0.500);
    padding-left: 250px;
    padding-right: 250px;
    margin-left: 250px;
    margin-right: 250px;
}
div.sideBarLeft {
     overflow: scroll;
     float: left;
}

How can I make the sidebar on the left rather than on top?

1 Answers

Helloo,

div.sideBarLeft {
  height: 100%;
  width: 160px;
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  background-color: #111;
  overflow-x: hidden;
  padding-top: 20px;
}

you can try this for navbar on left side

Related