Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Results summary component

Karl Davis 270

@TKD5

Desktop design screenshot for the Results summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


This is my version of the Results summary component.

I have a question for the community. A lot of these projects require a <div></div> to be in the center of the page. As a container.

I feel my approach is not the best way. Is there a standard way to center a div in the middle of a page?

Your answers will be greatly appreciated.

As always, Happy Codding!!

Community feedback

jetskeeter 180

@jetskeeter1

Posted

A lot of it requires a container div as far as I can tell and in my own experience. Without having a container that spans both height and width, then you would more likely have to hard code it using transform: translate, margin, and etc... but hard coding are never really good and is not really responsive. The easiest solution would be having to have a container that span both width:100%, height: 100vh, and display the container to flex and then you use justification-content: center; and align-items: center;. It will display the contents to the center of the screen.

Here is a video that I like that I found in youtube made by @Fireship: https://www.youtube.com/shorts/njdJeu95p6s

1

Karl Davis 270

@TKD5

Posted

@jetskeeter1 thanks for your advice. I'll check out that YouTube video.

0

@NikNT

Posted

Hey @TKD5

Nice work.

There is a very easy and optimal way to center a div.

<div class = "container"> <div class = "wrapper"> </div> </div>

Let's say we want to center the 'wrapper' div.

Simply, we can give <container> a height of 100vh and a width of 100vw. This will span the container to the entire screen.

Now, give these properties to <container>

display: flex; justify-content: center; align-items: center;

And, voila! your <wrapper> div will be centered!

Let me know, if you need any other help.

1

Karl Davis 270

@TKD5

Posted

@NikNT thanks for your advice. I'll definitely try out that method.

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord