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

137
Views
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 answers
Answer question

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 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!