Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
HTML CSS Vertical Line with exact height of a div

enter image description here

I've got a div element with some content (shown in the picture). I want (for styling purposes) create a vertical line next to it with the exact same height (needs to be responsive so a static "height" value isnt working)

Does anybody have ideas?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Option #1 - Set Border of Outer Element

.content {
  border-left: 2px solid #000;
  padding: 0 0.5rem;
}
.content p {
  max-width: 80%;
}
<div class="content">
  <p>
    Petierunt uti sibi concilium totius Galliae in diem certam indicere. Morbi fringilla convallis sapien, id pulvinar odio volutpat. A communi observantia non est recedendum.
    Non equidem invideo, miror magis posuere velit aliquet. Quisque placerat facilisis egestas cillum dolore. Curabitur blandit tempus ardua ridiculus sed magna. Contra legem facit qui id facit quod lex prohibet. Petierunt uti sibi concilium totius Galliae in diem certam indicere.
  </p>
</div>

Option #2 - Create Element with Full Height

.content {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  height: 10rem;
}

.content .line {
  height: 100%;
  width: 2px;
  background: #000;
  margin-right: 0.5rem;
}
<div class="content">
  <p>
    Petierunt uti sibi concilium totius Galliae in diem certam indicere. Morbi fringilla convallis sapien, id pulvinar odio volutpat. A communi observantia non est recedendum.
    Non equidem invideo, miror magis posuere velit aliquet. Quisque placerat facilisis egestas cillum dolore. Curabitur blandit tempus ardua ridiculus sed magna. Contra legem facit qui id facit quod lex prohibet. Petierunt uti sibi concilium totius Galliae in diem certam indicere.
  </p>
  <div class="line"></div>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

Put a div inside your container, make your container relative and make that div absolute with top and bottom as 0.

.container{
  position: relative;
}

.line{
  width: 4px;
  background-color: red;
  position:absolute;
  top: 0;
  bottom:0;
}
about 4 years ago · Juan Pablo Isaza Report

0

You can attain it using a simple border on the left.

.mytext {
  border-left:3px solid red;
  padding-left:15px;
  }
<div class="mytext">
<h1>Head<h1>
<p>text here</p>
<p>text here</p>
<p>text here</p>
<p>text here</p>
<p>text here</p>
<p>text here</p>
<p>text here</p>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!