how do I center this popup?

I tried but this center code wont work and its all I know:

<style>

.center-image {

  display: block; 

  margin-left: auto; 

  margin-right: auto; 

}


this is my code:


body:before {

content: " ";

height: 30vh;

width: 40vw;

display: block;

position: fixed; 

top: 0; 

left: 0; 

z-index: 100;

background-image: url('https://i.postimg.cc/9fpGS5PK/H-hi-there.gif');

background-size: cover;

background-repeat: no-repeat;

background-position:center;

animation: yourAnimation 9s ease 0s 1 normal forwards;

pointer-events: none;}

@keyframes yourAnimation { 0.0%{ opacity: 1;} 75%{ opacity: 1; } 100%{ opacity: 0;} } 

</style>


please help me I suck at html and im taking computer science next semester


 it works on my profile but it looks like this:



Screenshot-2025-12-03-at-15-47-23

everything about it works perfectly fine except for the centring so help would be appreciated :)


0 Kudos

Comments

Displaying 1 of 1 comments ( View all | Add Comment )

[_Mitch_]

[_Mitch_]'s profile picture

You need to change the value on this part

top: 0;
left: 0;

This is the one that controls your popup position. Just put numbers until is in the place you want it.


Report Comment



thank you :0 it helped on the code test site and it entered but it wont work on my profile or anywhere on spacehey actually and just stays in the corner :/

by *:・゚✧LilPinkPeppermintCandies /ᐠ. 。.ᐟ\ᵐᵉᵒʷˎˊ˗; ; Report

You can also just use other code for images. Maybe they one you had it's not correctly coded.

Try this code and just replace the url with the one on your correctly coded

—div style="float: ; max-height: 400px; position: fixed; right: -30px; bottom: 10px; z-index: 200;"—img src="URL_HERE" alt="GIF"/——/div—

Don't forget to replace the — with <> as you need it.

by [_Mitch_]; ; Report