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

147
Vistas
Width attribute not acting properly on my webpage

I am new at web development and facing some problem in creating a web page. Actually, I was creating a loading bar animation at the top of the window and set its width to 100vw but it is taking more space than it should take. Here's a picture to demonstrate:

As you can see in the top-right corner it is overflowing the window. Why is that so?

Here's my code:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Loading Bar</title>
    <style>
        #progress{
            background-color: red;
            height: 3px;
            width: 0vw;
            transition: width 3s ease-in-out;
        }
        *{
            margin: 0;
            padding: 0;
        }
        header {
            height: 122px;
            background-color: black;
        }
        main {
            height: 899px;
            background-color: blue;
        }
    </style>
</head>

<body>
    <div id="progress"></div>
    <header></header>
    <main>
        <button id="btn">Reload</button>
    </main>
</body>

<script>
    btn.addEventListener("click", ()=>{
        progress.style.width = "100vw"
    })
</script>
</html>

Thanks in advance!!

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try adding max-width: 100% to your progress bar css, according to https://caniuse.com/viewport-units there is a known issue on firefox in which the 100vw considers the entire length of the page including the vertical scrollbar as its width. This vertical scrolls is what making your webpage have an horizontal overflow.

about 4 years ago · Juan Pablo Isaza Denunciar

0

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Loading Bar</title>
    <style>
        body{ overflow-x: hidden; }
        #progress{
            background-color: red;
            height: 3px;
            width: 0vw;
            transition: width 3s ease-in-out;
        }
        *{
            margin: 0;
            padding: 0;
        }
        header {
            height: 122px;
            background-color: black;
        }
        main {
            height: 899px;
            background-color: blue;
        }
    </style>
</head>

<body>
    <div id="progress"></div>
    <header></header>
    <main>
        <button id="btn">Reload</button>
    </main>
</body>

<script>
    btn.addEventListener("click", ()=>{
        progress.style.width = "100vw"
    })
</script>
</html>

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