How to align top of picture with header title?
Hey everybody, I'm a beginner software dev and I'm currently working on a practice flexbox project, I wanted the top of my image to line up exactly with my header title "Heroes for Hire" and I can't think of a way to do this although I'm sure there is, anybody able to help? Here is a pen: https://codepen.io/Oothman/pen/MWMRwGB
8 Replies
This might be simpler in grid but, assuming that you want, or are limited to do this in flex, you need to have 2 children within your header.
The first one to hold the title and text and the second one to hold the image.
So your header-content HTML might look like this:
Then, in the CSS for this header-content wrapper you need to have flex and remove the flex-wrap and width that you have defined along the way.
The CSS for this part might look like this:
You should be using either
rem
or em
for font sizing. Using pixels ignores your user's preferences and is not responsive at all. Please use rem
for font sizing!Thank you so much, appreciate it! Yeah this is specifically a flexbox exercise and I'm yet to look at grid at all in the course.
Love your finger-gunz emoji! :fingerguns_skeleton:
Thank you very much, yeah I actually read an article about this exact topic a few days ago but was just focusing on positioning with flexbox so forgot about it, really appreciate the reminder!
Best to start early to burn it into your muscle memory so it becomes habit, IMO
I totally agree on using em or rem for font-sizing. I just didn't want to distract from the original question.
Definitely agree, always best to drill in good habits early! In fact, I realise now that the course styling sheet provided has the text sizes given in pixels which is probably what made me go with that, I'll make the suggestion to the organisers to switch it to rem for best practice :thanks: