Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to move Top bar to left side in css?

I have this div that shows a top red bar. I’ve been trying to move this bar to the left side and make it look like a border left, but not having any luck. Does anyone know how to make it look like a border left using this code? Thanks in advance!

.container {
  position: relative;
  width: 100%;
  padding: 18px;
  margin-bottom: 16px;
  border-radius: 8px;
  border: solid 2px #e1e4e8;
  overflow: hidden;
}

.container::after {
  content: '';
  position: absolute;
  display: block;
  height: 6px;
  width: 100%;
  top: 0;
  left: 0;
  background-color: red;
}
<div class = "container">this is a text</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This example adjusted position of ::after to make the red border appear on the left, hopefully close to the desired result.

.container {
 position: relative;
  width: 100%;
  padding: 18px;
  margin-bottom: 16px;
  border-radius: 8px;
  border: solid 2px #e1e4e8;
  overflow: hidden;
}

.container::after {
    content: '';
    position: absolute;
    display: block;
    width: 6px;
    inset: 0;
    background-color: red;
  }
<div class = "container">this is a text</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading