I am trying to create the main menu bar of my site. However while it works fine when the browser is in full size, when I resize the menu bar collapses, with half of the choices appearing in a line below the others while I want them to remain in line even if some of them will not be visible.
What can I do using HTML and CSS in order to make the choices of the menu bar to remain in a single line even when the line is not fully visible? I 've already tried every possible position in the main menu and the linking class, adding width with percentage and pixels and adding transition and fixed position combination. Nothing helped.
.main-menu {
background-color:grey;
font-weight:bold;
font-size:xx-large;
color: black;
}
.linking {
text-decoration: none;
color: white;
margin-right: 100px;
border:solid 2px;
border-color: red;
}
<p class="main-menu">
ΦΟΙΤΗΤΕΣ
ΓΡΑΜΜΑΤΕΙΑ
ΕΚΔΟΤΗΣ
....
</p>
May be this helps you. Have a look at the below code snippet.
.main-menu {
background:grey;
font-weight:bold;
font-size:xx-large;
color: #000;
overflow:hidden; /*to hide on collapse*/
height:1em;
}
.linking {
text-decoration: none;
color: #FFF;
margin: 0 100px 0 0;
border:2px solid red;
}
<p class="main-menu">
ΦΟΙΤΗΤΕΣ
ΓΡΑΜΜΑΤΕΙΑ
ΕΚΔΟΤΗΣ
....
</p>
Preview at https://jsfiddle.net/itsselvam/8wvb4k9o/
Please use below css property to do the same
.main-menu
{
background-color:grey;
font-weight:bold;
font-size:xx-large;
color: black;
max-width: 100%;
min-width: 1000px;
}
.linking
{
text-decoration: none;
color: white;
margin-right: 100px;
border:solid 2px;
border-color: red;
}
<p class="main-menu">
<a href="studenthome.html" class="linking">
ΦΟΙΤΗΤΕΣ
</a>
<a href="secrethome.html" class="linking">
ΓΡΑΜΜΑΤΕΙΑ
</a>
<a href="publisherhome.html" class="linking">
ΕΚΔΟΤΗΣ
</a>
<a href="sellerhome.html" class="linking">
Try This:
.main-menu {
background-color:grey;
font-weight:bold;
font-size:xx-large;
color: black;
}
.main-menu .linking {
background-color:grey;
text-decoration: none;
color: white;
margin-right: 100px;
border:solid 2px;
border-color: red;
/* added new css */
width: 24%; /* give width of 24% as you have 4 a-links each having 1px border */
position: fixed; /* set position fixed */
}
<p class="main-menu">
ΦΟΙΤΗΤΕΣ <!-- set left 0% as first child -->
ΓΡΑΜΜΑΤΕΙΑ <!-- set left 25% as second child -->
ΕΚΔΟΤΗΣ <!-- set left 50% as third child -->
.... <!-- set left 75% as fourth child -->
</p>
I am fairly new to CSS and HTML.
And I understand that this question has been asked several times, yet I cannot seem to fix my current issue.
I have been working on little small projects like trying to recreate other websites with extra features.
My current task is recreating a front page search area, such as google.
Implementation and Issue
I have been focusing in the responsiveness of websites when a browser resize occurs, so I have been using Flexbox as often as possible.
Implementation
A main div with a container id, with a min-height of 100% and a relative position.
Inside the container div are nav(#nav), center(#center) and footer(#footer) elements and their respective id's.
nav: a flex display, baseline align-items and min-height of 9vh.
center: a width of 100%, and a min-height of 10vh;
footer: absolute position, bottom 0, width of 100%
I have made some research into the Footer and how to keep it at the bottom of a page while being responsive when shrinking the browser, but I seem to have come to a halt or possibly I haven't fully understood yet how to get the footer to stop at a certain element.
Issue
The issue is that I cannot get the footer to function correctly. I do not wish it to overlaps with the bottons and links in the main content. It stops at the search bar when resizing the browswer, but I would like it to stop when it meets the buttons.
As you will see from the block of code snippets in the JSbin link, I have an issue with the footer.
Current HTML + CSS files and output: JSBin
*{
margin: 0px;
padding: 0px;
}
html, body {
height: 100%;
}
#container {
min-height:100%;
position:relative;
}
a:visited{
color: #609;
}
/* ----- Navigation Styling ----- */
#nav {
display: flex;
border: 10px solid goldenrod; /*Colourful Borders*/
min-height:9vh;
justify-content:flex-end;
align-items: baseline;
background:#ff0;
padding:10px;
}
/*Nav Content*/
/* ----- Center Styling ----- */
#center {
width: 100%;
background-color: white;
min-height:10vh;
}
.ctr_img {
height: 92px;
width: 272x;
padding-top: 20px;
}
.ctr_img:hover {
-webkit-filter: invert(100%);
}
.img_mic {
padding: 0 8px;
float: right;
display:inline-block;
top: -30px;
position: relative;
}
.srch_bx {
border-style: hidden;
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08);
max-width: 40%;
min-height: 40px;
}
.srch_in {
width: 100%;
border-radius: 2px;
border: none;
overflow: auto;
outline: none;
left: 0px;
background: url(data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D) transparent;
font: 16px arial,sans-serif;
display: inline-block;
text-align: start;
}
.mic_set {
background-size: 30px 30px;
height: 100%;
width: 26px;
}
.btn_sbmt {
padding: 20px 50%;
min-height: 20px;
display: flex;
justify-content: center;
}
.btn_srch, .btn_lcky {
background-color: #f2f2f2;
border: 1px solid #f2f2f2;
border-radius: 2px;
color: #757575;
font-family: arial,sans-serif;
font-size: 1vw;
font-weight: bold;
margin: 11px 4px;
padding: 0 16px;
height: 36px;
}
.lang_diff{
max-height: 28px;
font-size: 0.9vw;
margin-bottom: 24px;
font-family: arial,sans-serif;
}
/* Footer Styling */
#footer {
position:absolute;
bottom:0;
height: 5.2em; /* Height of the footer */
width: 100%;
min-height: 10vh;
background-color: #f2f2f2;
line-height: 40px; /*Specifies the line height.*/
min-width: 400px;
}
.ctry {
display: flex;
margin-left: 30px;
text-align: left;
color: rgba(0,0,0,.54);
border-top: 1px solid #e4e4e4;
max-width: 150px;
}
.ctry_ftr {
font-size: 1vw;
}
.opt_ftr {
display: flex;
justify-content:space-between;
border: 1px solid #e4e4e4;
}
span.blft_ftr a, span.brght_ftr a, span.brght_stg a {
text-decoration: none;
color: #666;
margin-left: 16px;
font-size: 1vw;
}
.brght_ftr{
margin-right: 30px;
float: right;
}
.adv_ftr {
padding: 0 16px;
text-decoration: none;
display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<title>Testing Ground</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="reset.css" />
<link rel="icon" href="http://www.favicon.cc/logo3d/53653.png" />
<meta charset="UTF-8">
</head>
<body> <!--FLEX-->
<div id="container"> <!-- Added New for Footer behaviour -->
<nav id="nav" class="nav_cls">
<!--Currently at work-->
<p>Navigation Bar Content</p>
</nav>
<center id="center">
<a class="img_link" href="">
<img class="ctr_img" src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/PM5544_with_non-PAL_signals.png/250px-PM5544_with_non-PAL_signals.png" alt="image">
</a>
<div class="in_forms">
<div class="srch_bx">
<form>
<input class="srch_in" type="text" name="search"/>
</form>
<div class="img_mic">
<a href="https://youtu.be/Ye8mB6VsUHw ">
<img class="mic_set" src="https://cdn.sesamestreet.org/sites/default/files/1496328210/Cookie_Big.png" />
</a>
</div>
</div>
</div>
<div>
<div class="btn_sbmt">
<input class="btn_srch" type="submit" value="Don't Hide me!" name="search"/>
<input class="btn_lcky" type="submit" value="Seriously, Don't!" name="luck"/>
</div>
</div>
<div class="lang_diff">
Links:
<a class="lang" href="">Link1</a>
<a class="lang" href="">Link2</a>
<a class="lang" href="">Link3</a>
<a class="lang" href="">Link4</a>
<a class="lang" href="">Link5</a>
</div>
</center>
<footer id="footer">
<div class="ctry">
<span class="ctry_ftr">
First half of a footer
</span>
</div>
<div class="opt_ftr">
<span class="blft_ftr">
<a class="adv_ftr" href="">Footer Link 1</a>
<a class="adv_ftr" href="">Footer Link 2</a>
<a class="adv_ftr" href="">Footer Link 3</a>
</span>
<span class="brght_ftr">
<a class="adv_ftr" href="">Footer Link 4</a>
<a class="adv_ftr" href="">Footer Link 5</a>
</span>
</div>
</footer>
</div>
</body>
</html>
Visited Websites
Footer is displayed over content. I need it always on the bottom of the page
HTML, CSS - Sticky footer displays over content on screen resize
Footer is displayed over content. I need it always on the bottom of the page
How to keep footers at the bottom of the page
Sticky Footer
Footer overlaps main content when window shrunk
:)
Congratulations, first of all, for following the rules of asking on SO.
Your problem comes from placing your footer out of document flow (position:absolute). It looks like you want it placed in document flow. So change position:absolute into position:relative (or static).
To keep it at the bottom of the screen at all times, adjust your #container to display:flex;flex-direction:column;min-height:100vh and make #center grow:
#footer {
position:static; /* this is default value of position
* so you could just remove `position:absolute`
* from your code.
*/
}
#container {
min-height: 100vh;
display: flex;
flex-direction: column;
}
#center {
flex-grow: 1;
}
See it working:
* {
margin: 0px;
padding: 0px;
}
html,
body {
height: 100%;
}
#container {
min-height: 100%;
position: relative;
}
a:visited {
color: #609;
}
/* ----- Navigation Styling ----- */
#nav {
display: flex;
border: 10px solid goldenrod;
/*Colourful Borders*/
min-height: 9vh;
justify-content: flex-end;
align-items: baseline;
background: #ff0;
padding: 10px;
}
/*Nav Content*/
/* ----- Center Styling ----- */
#center {
width: 100%;
background-color: white;
min-height: 10vh;
}
.ctr_img {
height: 92px;
width: 272x;
padding-top: 20px;
}
.ctr_img:hover {
-webkit-filter: invert(100%);
}
.img_mic {
padding: 0 8px;
float: right;
display: inline-block;
top: -30px;
position: relative;
}
.srch_bx {
border-style: hidden;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08);
max-width: 40%;
min-height: 40px;
}
.srch_in {
width: 100%;
border-radius: 2px;
border: none;
overflow: auto;
outline: none;
left: 0px;
background: url(data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D) transparent;
font: 16px arial, sans-serif;
display: inline-block;
text-align: start;
}
.mic_set {
background-size: 30px 30px;
height: 100%;
width: 26px;
}
.btn_sbmt {
padding: 20px 50%;
min-height: 20px;
display: flex;
justify-content: center;
}
.btn_srch,
.btn_lcky {
background-color: #f2f2f2;
border: 1px solid #f2f2f2;
border-radius: 2px;
color: #757575;
font-family: arial, sans-serif;
font-size: 1vw;
font-weight: bold;
margin: 11px 4px;
padding: 0 16px;
height: 36px;
}
.lang_diff {
max-height: 28px;
font-size: 0.9vw;
margin-bottom: 24px;
font-family: arial, sans-serif;
}
/* Footer Styling */
#footer {
/* position: absolute;
bottom: 0; */
height: 5.2em;
/* Height of the footer */
width: 100%;
min-height: 10vh;
background-color: #f2f2f2;
line-height: 40px;
/*Specifies the line height.*/
min-width: 400px;
}
.ctry {
display: flex;
margin-left: 30px;
text-align: left;
color: rgba(0, 0, 0, .54);
border-top: 1px solid #e4e4e4;
max-width: 150px;
}
.ctry_ftr {
font-size: 1vw;
}
.opt_ftr {
display: flex;
justify-content: space-between;
border: 1px solid #e4e4e4;
}
span.blft_ftr a,
span.brght_ftr a,
span.brght_stg a {
text-decoration: none;
color: #666;
margin-left: 16px;
font-size: 1vw;
}
.brght_ftr {
margin-right: 30px;
float: right;
}
.adv_ftr {
padding: 0 16px;
text-decoration: none;
display: inline-block;
}
#footer {
line-height: 2.42em;
}
#container {
min-height: 100vh;
display: flex;
flex-direction: column;
}
#center {
flex-grow: 1;
}
<div id="container">
<!-- Added New for Footer behaviour -->
<nav id="nav" class="nav_cls">
<!--Currently at work-->
<p>Navigation Bar Content</p>
</nav>
<center id="center">
<a class="img_link" href="">
<img class="ctr_img" src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c4/PM5544_with_non-PAL_signals.png/250px-PM5544_with_non-PAL_signals.png" alt="image">
</a>
<div class="in_forms">
<div class="srch_bx">
<form>
<input class="srch_in" type="text" name="search" />
</form>
<div class="img_mic">
<a href="https://youtu.be/Ye8mB6VsUHw ">
<img class="mic_set" src="https://cdn.sesamestreet.org/sites/default/files/1496328210/Cookie_Big.png" />
</a>
</div>
</div>
</div>
<div>
<div class="btn_sbmt">
<input class="btn_srch" type="submit" value="Don't Hide me!" name="search" />
<input class="btn_lcky" type="submit" value="Seriously, Don't!" name="luck" />
</div>
</div>
<div class="lang_diff">
Links:
<a class="lang" href="">Link1</a>
<a class="lang" href="">Link2</a>
<a class="lang" href="">Link3</a>
<a class="lang" href="">Link4</a>
<a class="lang" href="">Link5</a>
</div>
</center>
<footer id="footer">
<div class="ctry">
<span class="ctry_ftr">
First half of a footer
</span>
</div>
<div class="opt_ftr">
<span class="blft_ftr">
<a class="adv_ftr" href="">Footer Link 1</a>
<a class="adv_ftr" href="">Footer Link 2</a>
<a class="adv_ftr" href="">Footer Link 3</a>
</span>
<span class="brght_ftr">
<a class="adv_ftr" href="">Footer Link 4</a>
<a class="adv_ftr" href="">Footer Link 5</a>
</span>
</div>
</footer>
</div>
Another minor issue which needed addressing was using line-height expressed in px for #footer while its height was expressed in em, causing the page to develop a vertical scrollbar. line-height:2.42em fixes it.
On a different note, it would be unfair of me to give you this answer without mentioning the major accessibility problem your example has from lowering font-size on narrow devices. Try opening the example page on any mobile and you'll understand what I mean. At all times, elements in your page should keep a font-size allowing users to read.
The main purpose of web pages is to present content. If you present the content in a form disabling user ability to receive the message, your page does not perform its function.
#footer is positioned absolutely, which means that the parent container doesn't know how big it is (i.e. it is outside of the "document flow"). #container's height is set to min-height: 100%, so at a minimum, it needs to be the full height of the parent (in this case, the body), but if the child content is taller, it will stretch to accommodate that extra height.
Because #footer is not considered when#container is trying to figure out it's height, #container is just making sure it can fit it's other position: static or position:relative children.
So, when you scale down the height of your browser so it is very short, #container is too short - it doesn't leave space for the #footer.
There are a few ways to take care of this, though it is tricky from a responsive perspective if the height of the #footer is variable depending on the content and whether it wraps, etc.
If you know the height, you can add that amount of padding on the bottom of #container (if box-sizing: border-box; is turned on, it will not add onto the height: 100% - it will be included) and it will reserve the space for the #footer.
If you don't know the height, you could leverage display: flex; to fill the full height and have the footer self-align to the bottom, without needing to use position: absolute;. Flexbox has a bit of a learning curve though, I would recommend you read through some tutorials. http://flexboxfroggy.com/ is a fun game that can also help to learn it.
I'm going through freecode camp to learn coding and am working on my personal portfolio page here (https://codepen.io/DerekDenHartigh/pen/ypgvKV) I've got buttons at the top and I'm having a really hard time modifying the text - I had to use HTML h2 element to get the right size font because none of my CSS would apply to it. Now I'd like to vertically center the text but am not sure how. Thanks!
body{
background-color: lightgrey
}
#Banner{
height: 70px;
text-align: center;
border: 5px solid black;
border-radius: 10px;
}
button{
height: 60px;
background-color: grey;
font-size: 20px;
}
button:hover {
background-color: #D2B48C;
color: white;
}
#bAboutMe{
width:calc(100%/3);
background-color: grey;
}
#bProgrammingProficiencies{
width:calc(100%/3);
background-color: grey;
border-left: 5px solid black;
border-right: 5px solid black;
}
#bContcactInfo{
width:calc(100%/3);
background-color: grey;
}
<div class="row" id="Banner">
<div class=column id="bAboutMe">
<button class="btn btn-block"><h2>About Me</h2></button>
</div>
<div class=column id="bProgrammingProficiencies">
<button class="btn btn-block"><h2>Programming Proficiencies</h2></button>
</div>
<div class=column id="bContcactInfo">
<button class="btn btn-block"><h2>Contact Information</h2></button>
</div>
</div>
Your <h2> are applied css bootstrap with margin-top:20px; margin-bottom:10px. U just need to set these two to 0
h2 {
margin:0;
}
or
h2{
margin-top:0;
margin-bottom:0;
}
What seems to be an easy HTML page and CSS set up I have come up to an issue. I am trying to make a DIV fill up the rest of the page and meet with the DIV at the bottom.
I have researched all through the web and tried many options I have come across.
It seems the most popular way is to use position:absolute but when I do that my Google map disappears. It will also not let me change the position of the Google Map DIV from relative.
At the moment it is displaying as you can see from my image. I would like the #map DIV to center and fill up the remainder of the space available.
My site in Chrome element view
My HTML code:
<div id="wrapper">
<div id="header">
<h1>Find a Car Park</h1>
</div>
<div id="section">
<input type="text" id="town" placeholder="Search for Town.." onkeypress="handle(event)" />
<input type="button" value="Find Car Parks" onclick="codeAddress()" />
<input type="button" value="View All" onclick="getAllCarParks()" />
<input type="button" value="Your Location" onclick="loadUserScript()" />
</div>
<div id="map">
<div id="googleMap">
</div>
</div>
<div id="footer">
<p>hello</p>
</div>
</div>
</body>
My CSS code:
body{
margin:0;
font-family: 'Cabin', sans-serif;
}
#header {
background-color:#2d89ef;
color:white;
text-align:center;
padding: 20px;
}
#wrapper{
position:absolute;
height:100vh;
width:100vw;
}
#section {
text-align:center;
padding-bottom:15px;
padding-top:15px;
width:100vw;
}
#footer {
background-color:#2c3e50;
color:white;
clear:both;
text-align:center;
padding-top:10px;
padding-bottom:10px;
bottom:0;
position:absolute;
width:100vw;
}
#map {
height:auto;
}
#googleMap{
height:65%;
}
input[type=button], input[type=submit], input[type=reset] {
background-color: #2d89ef;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
border-radius: 4px;
}
input[type=text] {
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
color: darkgrey;
background-color: white;
background-image: url('../images/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
}
Try using flexbox instead.
https://css-tricks.com/centering-css-complete-guide/
<div style="display:flex;justify-content:center;align-items:center;">
<div></div>
</div>
Try this CSS code on the #map, it will makes your map full width and height of the page :
#map {
display: block;
width: 100%;
height: 100%;
}
Fiddle
I want to have a navigation bar with a logo inside it but as I add the logo the line doesn't look fine!
The problem is when I add the pic its like the picture and the text doesnt stay in the same line! not that the line breaks but the text slides down a little while it shouldn't.
body {
background-color: #C8F1BA;
margin: 0px;
}
div#gnb_bg {
margin: 0px;
padding-top: 0px;
padding-bottom: 0px;
border-right: 10px solid black;
}
a.gnb {
background-color: #99FF33;
text-decoration: none;
font-size: 26px;
border-right: 1px solid #448811;
padding-right: 2.5%;
padding-left: 2.5%;
padding-top: 14px;
padding-bottom: 14px;
margin: 0px;
}
img#gnb_logo {
height: 30px;
margin: 10px;
}
nav#gnb {
text-align: center;
background-color: #99FF33;
height: 50px;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<nav id="gnb" role="navigation" aria-label="Global Navigation">
<div id="gnb_bg">
<a class="gnb" href="../feedbacks/feedbacks.html">feedbacks</a>
<img id="gnb_logo" src="../images/logo.gif" />
</div>
</nav>
</body>
For starters we need to sort out your html.
Then look at your css your <a> if you're using padding etc you need to make it a block level element.
remove the height 50px from your nav that's not something you want to be giving height to. Instead use your padding of <a> to get the desired height it helps with responsive.
But because we want it to sit beside your image use inline-block
also do not use CSS to define an tag's height and width you should use the tags attributes so that rendering happens smoothly.
Also you need to use alt on images.
your image also needs the following css rule's:
img#gnb_logo {
vertical-align:middle;
margin:0 10px;
}
So that it sits the way you want it beside your link.
Also if that is your site's logo it should not be inside <nav>
If it's an icon relative to the link then instead of using <img> use background-image
body {
background-color: #C8F1BA;
margin: 0px;
}
ul,
li {
list-style: none;
}
div#gnb_bg {
margin: 0px;
padding-top: 0px;
padding-bottom: 0px;
border-right: 10px solid black;
}
a.gnb {
background-color: #99FF33;
text-decoration: none;
font-size: 26px;
border-right: 1px solid #448811;
padding-right: 2.5%;
padding-left: 2.5%;
padding-top: 14px;
padding-bottom: 14px;
margin: 0px;
display: inline-block;
}
img#gnb_logo {
vertical-align:middle;
margin:0 10px;
}
nav#gnb {
text-align: center;
background-color: #99FF33;
}
<header>
<nav id="gnb" role="navigation" aria-label="Global Navigation">
<ul id="gnb_bg">
<li>
<a class="gnb" href="../feedbacks/feedbacks.html">feedbacks</a>
<img id="gnb_logo" src="../images/logo.gif" height="30" alt="GNB Logo" />
</li>
</ul>
</nav>
</header>
If you add vertical-align: middle to both the a.gnb and img#gnb_logo, that will probably fix your problem.
Pay attention to the top/bottom padding on your link so that it does overflow the 50px height that you assigned to the parent container.
body {
background-color: #C8F1BA;
margin: 0px;
}
div#gnb_bg {
margin: 0px;
padding-top: 0px;
padding-bottom: 0px;
border-right: 10px solid black;
}
a.gnb {
background-color: #99FF33;
text-decoration: none;
font-size: 26px;
border-right: 1px solid #448811;
padding-right: 2.5%;
padding-left: 2.5%;
padding-top: 10px;
padding-bottom: 10px;
margin: 0px;
vertical-align: middle;
}
img#gnb_logo {
height: 30px;
margin: 10px;
vertical-align: middle;
}
nav#gnb {
text-align: center;
background-color: #99FF33;
height: 50px;
}
<nav id="gnb" role="navigation" aria-label="Global Navigation">
<div id="gnb_bg">
<a class="gnb" href="../feedbacks/feedbacks.html">feedbacks</a>
<img id="gnb_logo" src="http://placehold.it/100x50" />
</div>
</nav>
First your a.gnb class should have a display-block if you want to render padding on an inline tag like a "a" tag. And your line-height must be of 22px if you want to make it fit in a 50px height container (14px + 14px padding top and bottom + 22px line-height equal 50px)
Second, to make your image alignment just add vertical-align: middle to the img#gnb_logo rule:
body {
background-color: #C8F1BA;
margin: 0px;
padding: 0px;
}
div#gnb_bg{
margin:0px;
padding-top:0px;
padding-bottom:0px;
border-right:10px solid black;
}
a.gnb{
background-color: #99FF33;
text-decoration: none;
font-size:26px;
border-right:1px solid #448811;
padding-right:2.5%;
padding-left:2.5%;
padding-top:14px;
padding-bottom:14px;
margin:0px;
line-height: 22px;
display: inline-block;
}
img#gnb_logo{
height:30px;
margin:10px;
vertical-align: middle;
}
nav#gnb{
text-align:center;
background-color: #99FF33;
height: 50px;
}
You need to remove the margin.
img#gnb_logo{
height:30px;
margin:0px;
}
Check out the live demo.
body {
background-color: #C8F1BA;
margin: 0px;
}
#gnb{
padding:10px;
}
div#gnb_bg{
margin:0px;
padding-top:0px;
padding-bottom:0px;
border-right:10px solid black;
}
a.gnb{
background-color: #99FF33;
text-decoration: none;
font-size:26px;
border-right:1px solid #448811;
padding-right:2.5%;
padding-left:2.5%;
padding-top:14px;
padding-bottom:14px;
margin:0px;
}
img#gnb_logo{
height:30px;
}
nav#gnb{
text-align:center;
background-color: #99FF33;
height: 50px;
}
<nav id="gnb" role="navigation" aria-label="Global Navigation">
<div id="gnb_bg">
<a class="gnb" href="../feedbacks/feedbacks.html">feedbacks</a>
<img id="gnb_logo" src="http://placehold.it/100x50"/>
</div>
</nav>
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: #C8F1BA;
margin: 0px;
}
a.gnb {
text-decoration: none;
font-size: 26px;
border-right: 1px solid black;
vertical-align: middle;
padding-right: 1%;
padding-left: .2%;
padding-top: 5px;
padding-bottom: 5px;
}
img#gnb_logo {
height: 30px;
vertical-align: middle;
margin:5px 0px;
}
nav#gnb {
text-align: center;
background-color: #99FF33;
height: 40px;
}
</style>
</head>
<body>
<nav id="gnb" role="navigation" aria-label="Global Navigation">
<div id="gnb_bg">
<img id="gnb_logo" src="http://placehold.it/100x50" />
<a class="gnb" href="../feedbacks/feedbacks.html">Website</a>
</div>
</nav>
</body>