0
Why do I have extra space between elements?
I'm practicing creating layouts with CSS, and somehow I ended up with this space between the banner image and the navigation bar. Can someone tell me how to get rid of it? Neither element has top or bottom margins. https://code.sololearn.com/WySGfy7UDHdO/?ref=app
6 Answers
+ 2
Here your <ul> element has margins so:
/* Styles for main navigation */
#navbar {
list-style-type: none;
height: 25px;
width: 100%;
background-color: #36688d;
margin: 0;
}
You should add margin: 0;
It helps 80% avoid extra spaces.
+ 1
Your image can't fill its parent div with id #banner.
There lots of ways, try this
Add in your image
margin-bottom: - 5px; (maybe 6px ...)
#banner img {
height: 140px;
width: 100%;
margin-bottom: -5px;
}
And check, may be it looks different in mobile and computer displays.
And you can find another ways
Try again and again.
0
Muhammad Thank you, that helped! There is still a gap, but it's smaller now. Is it possible to completely remove it?
0
And I think your JQuery scripts do nothing now, if you remove your code nothing will change.
0
Thanks Muhammad ! And yes, the JQuery script was part of a separate experiment lol
0
Not at all good luck!