Design comparison
Solution retrospective
I had trouble experimenting with the different sizes with em and rem so I used pixels instead.
I am unsure of how to center containers within divs but I managed to center them with padding and margin.
What are the best ways to implement bootstrap links in HTML? Also what are the best ways to center divs within divs.
Thank you.
Community feedback
- @pengpongpongPosted over 1 year ago
Hey Ele!
I noticed you used in your index.html a lot of
link
tags for google fonts, but an easier way to import them is to use the import link from google. Select "@import" instead "<link>" when you're on google fonts webpage. Copy the import link, which should look something like this (I selected Inter font, with 400, 700 and 800 weight):@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;800&display=swap')
Add the import code snippet on top of your style.css file and now you can use the font in your
font-family
like so:font-family: 'Inter'
withfont-weight
400, 700 or 800 as you wish.Your
p
tag with "P E R F U M E" is one way to solve that, but better would be to useletter-spacing
in your CSS to space letters like so:letter-spacing: 2px
.Also try to use
section
andmain
tag for a more semantic approach.The way you added svg is one way, but you can also use
img
tag like so:<img src="SVG LINK"/>
. It's just a shorter way to implement svg.When using
rem
andem
you should know thatrem
is basically16px
, becauserem
is related to the root font-size. When you're usingem
it is taking its font-size based on its parent (and if parent has no font-size, it will take the font-size from the next parent until it reaches the root, which will be16px
again). So when you changefont-size
and you haveem
somewhere in it's children, that will affect the children's size also. That's why you should changefont-size
first and then the other elements.To center things you can use flexbox or grid.
display: grid place-content: center
or
display: flex justify-content: center align-items: center
place-content
is a shorthand property forjustify-content
andalign-content
.justify
is used for horizontal andalign
is used for vertical.justify-content
andalign-content
moves the whole container andjustify-items
andalign-items
moves the items inside the container. Most of the time you will usejustify-content
withalign-items
when using flexbox orplace-content
when using grid. Flex-box, W3-schools grid, W3-schools [Justify-content, W3-schools]](https://www.w3schools.com/cssref/css3_pr_justify-content.php) [Align-items, W3-schools]](https://www.w3schools.com/cssref/css3_pr_align-items.php)To center with margin you can use:
margin: 0 auto
That will setmargin-top
+margin-bottom
to 0 (you don't have to use 0) andmargin-left
+margin-right
will be centered, because withauto
it will use the remaining space equally on both side, which will center the element. Definitely useflex
orgrid
to center.For bootstrap you can add
link
tag to yourhead
tag in your index.html file.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
. You can also usescript
tag. Add thescript
tag to your body right before the closing</body>
tag. That is to ensure that your html is fully loaded before yourscript
tags will be executed.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