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

238
Views
div cutted when no vertical scroll in browser

I have the fallowing property:

div{width:300px;}

and everything is fine because there is a vertical scroll(with a width of 17px).

but when I have the same div in a place where there is no vertical scroll there is a void (cause there is no 17px vertical scrollbar of course)

My question is: what is the correct way to approach this problem?

something like this logic maybe?

if !scrollbarY 
then div.width=div.width + scrollbarY 
else div.width

or maybe placing a verticalscroll not having the need?

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

0

If you set div {overflow: scroll;}, scrollbar sections will show whether a scrollbar is needed or not (or void as you say). If you set div {overflow: auto;}, it will only show the scrollbar sections when necessary. Run the code snippet to see an example of both.

.one,
.two,
.three {
  width:300px;
  height: 50px;
  display: block;
  margin-bottom: 3rem;
  border: 1px solid pink
}

.one {
  overflow: scroll
}
.two,
.three {
  overflow: auto
}
<div class="one">
  jlnka sdflj knasd
</div>
<div class="two">
  jlnkasdf ljknas dflkjn.
</div>
<div class="three">
  jlnkasdf ljknas dflkjn asdflkj nasdflk jnasdfl kjnasdf lkjnasd flkjnas dflkjnas dflkjnas dflkjnas dfkljnas dfkljnas dlfkjnas
</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!