How do I center this

Status
This thread has been locked.

Annabella

QUIT - SERIOUS HEALTH ISSUES AND WELL YEAH :/
Banned
Feedback score
17
Posts
229
Reactions
116
Resources
0
Hey! trying to centre this image vertically but I'm stuck any ideas?

Screenshot 2020-02-23 at 18.51.17.png

Screenshot 2020-02-23 at 18.50.17.png
 

Attachments

  • Screenshot 2020-02-23 at 18.50.17.png
    Screenshot 2020-02-23 at 18.50.17.png
    39.1 KB · Views: 92
  • Screenshot 2020-02-23 at 18.51.17.png
    Screenshot 2020-02-23 at 18.51.17.png
    37.8 KB · Views: 94
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Shaun

Web Developer, owner of Syncore LLC
Supreme
Feedback score
20
Posts
622
Reactions
408
Resources
0
Absolute positioning (beginner friendly)

HTML:
<body>
    <div class="imageContainer">
        <img src="#" alt="#" class="image"/>
    </div>
</body>

Code:
.imageContainer{
    height: 100vh;
    width: 100vw;
}

.image{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%)
}

Here's the CodePen: https://codepen.io/Athys/pen/JjdEoXK


Flexbox (advanced)
Code:
.imageContainer{
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image{
    // Any other styling you want to apply to the image
}

Here's the CodePen: https://codepen.io/Athys/pen/poJRvyB
 
Last edited:

Annabella

QUIT - SERIOUS HEALTH ISSUES AND WELL YEAH :/
Banned
Feedback score
17
Posts
229
Reactions
116
Resources
0
Absolute positioning (beginner friendly)

HTML:
<body>
    <div class="imageContainer">
        <img src="#" alt="#" class="image"/>
    </div>
</body>

Code:
.imageContainer{
    height: 100vh;
    width: 100vw;
}

.image{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%)
}

Here's the CodePen: https://codepen.io/Athys/pen/JjdEoXK


Flexbox (advanced)
Code:
.imageContainer{
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image{
    // Any other styling you want to apply to the image
}
confusing but ty
 
Banned forever. Reason: Leaking user resources
Status
This thread has been locked.
Top