Design comparison
Solution retrospective
2 problems so far:
I didn't know how to group the "Music Icon" and "Annual Plan" together while having the whole row justified and vertically centered at the same time.
I used these rules to vertically centre my content in the body: body { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
The problem with this is that when I make my browser screen really short, let's say less than 500px, the top of the content starts to cut off and it won't scroll up.
So I fixed it by creating conditional CSS where I monitor the height of the screen. This is not elegant and I feel deeply ashamed :) Any advice on how to actually stick the content to the top of the screen, when the viewing height becomes too small, with the possibility to scroll, would be much appreciated.
Community feedback
- @denieldenPosted over 2 years ago
Hey Arthur, congratulations on completing the challenge! You did a great job ๐
Let me give you some little tips for optimizing your code:
- add
main
tag and wrap the card for improve the Accessibility - for fix the top image in the background just put more specific background properties to the body:
background: url("../img/pattern-background-desktop.svg") no-repeat top center; background-size: contain; background-color: #e0e8ff;
- remove
margin
from body to remove the scroollbar of browser - use
min-height: 100vh
and notheight
- add
transition
on the element with hover effect - instead of using
px
use relative units of measurement likerem
-> read here
Hope this help! Happy coding ๐
Marked as helpful2@ArthurPogPosted over 2 years ago@denielden 'Sup Daniel! Thank you for the heads up. I did most of what you said and it looks great. I am going to have to research and understand
rem
a little bit more before using it in my code (that and CSS variables and native HTML tags). I only just got the hang ofem
so there's still some work to be done :)Thank you for helping me fix the background issues. It now works as I originally intended.
1 - add
- @vanzasetiaPosted over 2 years ago
Hello, Arthur! ๐
Regarding the problem that you have:
- The music icon has a line height, maybe because the
img
element is an inline element. So, I recommend making theimg
element as a block element and (probably) settingline-height: 0
would solve the problem. - I highly recommend making the
body
element as a flexbox container to center the child element which should be the card element. Then, setmin-height: 100vh;
(**notheight
) to make the card vertically center and allow thebody
element to grow if needed. So, the point is to usemin-height
and flexbox instead. Also, add somepadding
as well to prevent the card from having full width on the small screen size.
Some feedback from me.
- All images on this site are decorative images. So, I recommend leaving the
alt
empty. - Don't use
br
elements for presentational purposes. Read what MDN documentation says about it. I would recommend making thespan
as block element to move the text to another line. - Always specify the
type
of thebutton
. In this case, set the type of them astype="button"
. It's going to prevent the button from behaving unexpectedly. - I would highly suggest using HTML native element instead of
role
attribute. It's best to use the native HTML element whenever possible.
That's it! Hope you find this useful!
Marked as helpful2@ArthurPogPosted over 2 years ago@vanzasetia Thank you, thank you and thank you, brother!
I fixed the vertically centred issue that I had (as first recommended by @OGShawnLee). I deleted the
alt
descriptions, made thespan
blocks, specified the button type and deleted thediv
classified as main and just put it in amain
native HTML tag.You rock!
0@OGShawnLeePosted over 2 years ago@ArthurPog I think you should have left them empty as he said instead of pulling out the big guns and completely remove them xD. An image must have an alt attribute, however you can leave them empty when the image is decorative.
Marked as helpful2@vanzasetiaPosted over 2 years ago@ArthurPog You're welcome! ๐
Yes, I agree with @OGShawnLee that
img
element needs analt
attribute. Just leave it empty. ๐Oh, I forgot to mention that put all the styling on the external stylesheet. Don't mix HTML and CSS (and also JavaScript). It's important because internal styling is hard to maintain (and not reuseable through out the project) because if you work with multi-page website and there's something wrong with one styling let's say on the
body
element then you have to remember to fix each styling on each HTML file.Marked as helpful2@ArthurPogPosted over 2 years ago@OGShawnLee Thanks again! I returned the
alt
's back :)0@ArthurPogPosted over 2 years ago@vanzasetia Yeah, I know CSS has to be separate. Just for this project and a few of the easier, one-page ones before I did it this way, because I was coding in codepen. Now that I moved to VS Code and using Live Previews, I will definitely save them in individual files. Muchos gracias :)
0 - The music icon has a line height, maybe because the
- @ArthurPogPosted over 2 years ago
Btw, does anyone have any clue why my generated screenshot is offset vertically by approximately 10 pixels? I have this with every project :)
0@ArthurPogPosted over 2 years ago@ArthurPog Just found out what it was if anyone is interested. Any
padding
ormargin
applied directly to thebody
causes this. I just moved the margin onto my main container and vois-lรก!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