Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

233
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda