r/beginnerwebdev • u/Meldzha • Jan 15 '19
Help needed with alignment
Hello guys,
I have a little problem with aligning things. First of all - I have a nav bar in header on the left, but I want to add an image (.png) with my logo which would be on the right but ON THE SAME LINE. Both bottoms of nav bar and logo are on the same line. Can you please help me? Thank you.
https://codepen.io/Meldzha/pen/maoEBX
EDITED: I somehow solved the problem if we look from users viewpoint, but I don't know HOW I did that. A lot of margin, padding and flexing...
7
Upvotes
2
u/Augnelli Jan 16 '19 edited Jan 16 '19
I noticed a few things.
You're using padding: none; instead of padding: 0;
The list of links should probably be in an actual list.
The Logo is using a margin-left to move it to the right. I'm guessing it looks good on your screen, but on smaller screen sizes, it's out of view.
You have block level styles on inline level elements.
The <a> tag is an inline element, giving it a margin will not work properly or as intended.
Block level elements: <div>, <h1> through <h6>, <p>, <ul>, <li>
Inline level elements: <a>, <span>, <b>, <img>
I made some changes to your HTML
I made some changes to your CSS, too:
Try throwing your original code and my edits into www.diffchecker.com/ for a better view of what changed.
Another useful link: codeburst.io/block-level-and-inline-elements
Overall, your work looks solid, just a few edits.
Edit: I realize I didn't give you any context to these changes. Later today, I'll probably have time to go through and give reasons for everything I did.