Design comparison
Solution retrospective
-
I still have trouble with moving elements using the directional properties like "top, bottom, right, left", as I think there are more efficient options than those;
-
I also have problem with measuring units for the elements. I don't seem to have the knowledge to decide how many px should this box be and all. Also, kind of connected to the first point, I'm confused whether or not we can use 'fr' unit as the unit for the aforementioned directional properties?
Community feedback
- @sean-b765Posted over 3 years ago
Can't preview your site but based on your code here are a few pointers:
- Don't use left/top on the body. The body is the container of your whole website, and you are effectively cutting out a large portion of it. Instead, have a container with your desired width/height inside the body.
- Look into display: flex/grid a bit more. Align-self works on child elements rather than the container. column-gap has no effect on a flex container. align-items will only apply to items within a container which has display-flex/grid specified. Your elements have display: inline-block
- To answer your second question, 'fr' is typically just used for grids. fr = fraction, if you have 4 columns 1fr = 1/4. You can use percentages, or calc(100%/3) to achieve a 1/3rd value. You could also use flex: 1; on each child item to get even widths for three flex-items: check this example
Good luck! :)
Marked as helpful1@FarizkeysPosted over 3 years ago@sean-b765 Hi Sean, thank you for your feedback!
-
I'm still figuring out how to move the elements that are sticking to the left by default. If left/top properties are not recommended, I should just tweak the width/height? Or is there any more ways to move the elements?
-
Well noted!
-
Well noted as well!
Thank you Sean!
0@sean-b765Posted over 3 years ago@Farizkeys Top/left in your case is better replaced with a margin or padding. Check this codesandbox link for how I'd approach it
With an auto margin you are horizontally centering the .container within its parent (body)
Then I fill the .container to the screen and set it as a flex with centered content.
Also note the box-sizing: border-box; If you remove this line you'll see the padding on the grey container is not accounted for in the width.
0
Please log in to post a comment
Log in with GitHubJoin 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