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

144
Vistas
Why does the CSS only apply when refreshed?

Div CSS loading issue

I have a simple php login system where the button calls on the JavaScript function loading() in order to display a div and an mp4 over the login. Kind of like a loading screen that always takes the same duration. The issue I have is whenever I load up the page the div and mp4 css isn't applied, resulting in it being displayed as shown in the video.

If I wait for the mp4 to end however and try again, (or even using CTRL + F5 to refresh) it fixes the issue and displays normally.

Am I doing something wrong resulting in this?

Any help would be much appreciated, thanks.

function loading() {
  var overlay = document.getElementById("overlay");
  overlay.style.display = 'flex';
}
.overlay {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  background-color: #62a6ff;
  width: 350px;
  height: 350px;
  border-radius: 40px;
  border-color: #85baff;
  border-style: solid;
  border-width: 7px;
  box-shadow: 0px 0px 10px 2px #000000;
}

.videoframe {
  margin-top: 25%;
  margin-left: 7%;
  width: 300;
  height: 169;
  box-shadow: 0px 0px 10px 2px #000000;
  background-color: #000000;
}

.backvideo {
  width: 300;
  height: 169;
}
<input class="button" id="submit" type="submit" value="Login" onclick="loading()">
<br>
<br>
<div id="pagechange2"><a href="signup.php">SignUp</a></div>
</form>
</div>
<div id="overlay" class="overlay" style="display:none">
  <div id="videoframe" class="videoframe">
    <video class="backvideo" autoplay muted crossOrigin="anonymous">
                    <source src="videos/background3s.mp4" type="video/mp4">
                </video>
  </div>
</div>

Screenshot

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

I fixed it and got it to work. I changed the following:

<video class="backvideo" autoplay muted crossOrigin="anonymous">

to:

<video id="backvideo" autoplay muted crossOrigin="anonymous">

I changed the class to an id

I then went to my CSS and changed .backvideo to #backvideo and then changed

.videoframe {
  margin-top: 25%;
  margin-left: 7%;
  width: 300;
  height: 169;
  box-shadow: 0px 0px 10px 2px #000000;
  background-color: #000000;
}

.backvideo {
  width: 300;
  height: 169;
}

to:

.videoframe{
    margin-top: 25%;
    margin-left: 7%;
    width: 300px;
    height: 169px;
    box-shadow: 0px 0px 10px 2px #000000;
    background-color: #000000;
 }

 #backvideo{
    width: 300px;
    height: 169px;
 }

adding px to both the width and height values

about 4 years ago · Santiago Gelvez 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