Float hamburger menu css - html

I'm new in css and I have pure hamburger css menu
Problem is the menu is part of page as absolute item, I want it to float and show always when page scroll, the position is just below the header:
Desired result:
And when menu is open take space of page and show an icon at the bottom of menu:
Snippet:
*{
box-sizing: border-box;
}
body{
font-family: 'Montserrat', sans-serif;
margin:0px;
}
.section-title{
color: #2ddf5c;
}
.main-header{
display: flex;
align-items: center;
justify-content: space-evenly;
width:100%;
/* background: #2ddf5c; */
padding: 16px;
}
.main-header > div{
vertical-align: middle;
}
.main-header__brand{
color: #7B8F34;
text-decoration: none;
font-weight: bold;
font-size: 20px;
}
.main-nav__searchbar_container {
display: flex;
width: 100%;
padding: 8px 8px 8px 40px;
overflow: hidden;
vertical-align: middle;
white-space: nowrap;
}
.main-nav__searchbar_container input.main-nav__searchbar{
width:100%;
height: 50px;
/* background: #2b303b; */
border: none;
font-size: 10pt;
float: left;
/* color: #fff; */
padding-left: 15px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.main-nav__searchbar_container input.main-nav__searchbar::-webkit-input-placeholder{
color: #65737e;
}
.main-nav__searchbar_container input.main-nav__searchbar:-moz-placeholder{ /*Frefox 18 */
color: #65737e;
}
.main-nav__searchbar_container input.main-nav__searchbar::-moz-placeholder{/*Frefox 19 */
color: #65737e;
}
.main-nav__searchbar_container input.main-nav__searchbar:-ms-input-placeholder{
color: #65737e;
}
.main-nav__searchbar_container button.icon{
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border: none;
background: #4f5b66;
height: 50px;
width: 50px;
color: #ffffff;
opacity: 0;
font-size: 10pt;
-webkit-transition: all .55s ease;
-moz-transition: all .55s ease;
-ms-transition: all .55s ease;
-o-transition: all .55s ease;
transition: all .55s ease;
}
.main-nav__searchbar_container:hover button.icon,
.main-nav__searchbar_container:active button.icon,
.main-nav__searchbar_container:focus button.icon{
outline: none;
opacity: 1;
margin-left: -50px;
}
.main-nav__searchbar_container:hover button.icon:hover{
background: red;
cursor: pointer;
}
input.main-nav__searchbar:hover{
border: 2px solid #4f5b66;
}
.main-nav__searchbar{
display: flex;
width: 100%;
/* margin: 8px; */
/* padding: 8px; */
border: 2px solid;
border-radius: 4px;
outline: none;
transition: .3s;
}
.main-nav{
display: flex;
width: 100%;
text-align: right;
margin: 0 10px;
}
.main-nav__items{
display: flex;
margin:8px;
padding:8px;
list-style: none;
}
.main-nav__item{
display: inline-block;
}
.main-nav__social{
display:block;
width: 35px;
height: 35px;
margin-left: 10px;
padding: 4px;
}
#main-slider {
width: 100%;
height: 528px;
/* border-radius: 0% 0% 50% 50% / 0% 0% 20% 20%; */
border-bottom-right-radius: 50% 25%;
border-bottom-left-radius: 50% 25%;
position: relative;
}
/* menu icon */
.main .menu-icon {
cursor: pointer;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.main .menu-icon .nav-icon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}
.main .menu-icon .nav-icon:before,
.main .menu-icon .nav-icon:after {
background: #333;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.main .menu-icon .nav-icon:before {
top: 5px;
}
.main .menu-icon .nav-icon:after {
top: -5px;
}
/* menu btn */
.main .menu-btn {
display: none;
}
.main .menu-btn:checked ~ .menu {
/* max-height: 240px; */
display: block;
}
.main .menu-btn:checked ~ .menu-icon .nav-icon {
background: transparent;
}
.main .menu-btn:checked ~ .menu-icon .nav-icon:before {
transform: rotate(-45deg);
top:0;
}
.main .menu-btn:checked ~ .menu-icon .nav-icon:after {
transform: rotate(45deg);
top:0;
}
#media (min-width: 48em) {
.main li a {
padding: 20px 30px;
}
.main .menu {
clear: none;
float: right;
max-height: none;
}
}
<header class="main-header">
<div>
<a href="index.html" class="main-header__brand">
uHost
</a></div><nav class="main-nav">
<div class=main-nav__searchbar_container><input type="text" placeholder="Search" class="main-nav__searchbar">
<button class="icon"><i class="fas fa-search" aria-hidden="true"></i></button>
</div>
<ul class="main-nav__items">
<li class="main-nav__item">
<img class="main-nav__social" src="navbar-icons/social-media__icons/facebook.svg" alt="facebook">
</li>
<li class="main-nav__item">
<img class="main-nav__social" src="navbar-icons/social-media__icons/instagram-bosquejado.svg" alt="instagram">
</li>
</ul>
</nav>
</header>
<div class="main">
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="nav-icon"></span></label>
<ul class="menu">
<li>Test1</li>
<li>Test2</li>
<li>Test3</li>
</ul>
</div>
<main>
<section>
<div class="slider-wrapper">
<img id="main-slider" src="https://via.placeholder.com/1365x528?text=Slider">
</div>
</section>
I try to change position:fixed instead position: absolute on
.main .menu-icon .nav-icon:before,
.main .menu-icon .nav-icon:after
class, but it no works, hamb menu bars disappear and some strange effect happen when it opens
Regards

Add this style on your style it is solution:
*{
box-sizing: border-box;
}
body{
font-family: 'Montserrat', sans-serif;
margin:0px;
}
.section-title{
color: #2ddf5c;
}
.main-header{
display: flex;
align-items: center;
justify-content: space-evenly;
width:100%;
/* background: #2ddf5c; */
padding: 16px;
}
.main-header > div{
vertical-align: middle;
}
.main-header__brand{
color: #7B8F34;
text-decoration: none;
font-weight: bold;
font-size: 20px;
}
.main-nav__searchbar_container {
display: flex;
width: 100%;
padding: 8px 8px 8px 40px;
overflow: hidden;
vertical-align: middle;
white-space: nowrap;
}
.main-nav__searchbar_container input.main-nav__searchbar{
width:100%;
height: 50px;
/* background: #2b303b; */
border: none;
font-size: 10pt;
float: left;
/* color: #fff; */
padding-left: 15px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.main-nav__searchbar_container input.main-nav__searchbar::-webkit-input-placeholder{
color: #65737e;
}
.main-nav__searchbar_container input.main-nav__searchbar:-moz-placeholder{ /*Frefox 18 */
color: #65737e;
}
.main-nav__searchbar_container input.main-nav__searchbar::-moz-placeholder{/*Frefox 19 */
color: #65737e;
}
.main-nav__searchbar_container input.main-nav__searchbar:-ms-input-placeholder{
color: #65737e;
}
.main-nav__searchbar_container button.icon{
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border: none;
background: #4f5b66;
height: 50px;
width: 50px;
color: #ffffff;
opacity: 0;
font-size: 10pt;
-webkit-transition: all .55s ease;
-moz-transition: all .55s ease;
-ms-transition: all .55s ease;
-o-transition: all .55s ease;
transition: all .55s ease;
}
.main-nav__searchbar_container:hover button.icon,
.main-nav__searchbar_container:active button.icon,
.main-nav__searchbar_container:focus button.icon{
outline: none;
opacity: 1;
margin-left: -50px;
}
.main-nav__searchbar_container:hover button.icon:hover{
background: red;
cursor: pointer;
}
input.main-nav__searchbar:hover{
border: 2px solid #4f5b66;
}
.main-nav__searchbar{
display: flex;
width: 100%;
/* margin: 8px; */
/* padding: 8px; */
border: 2px solid;
border-radius: 4px;
outline: none;
transition: .3s;
}
.main-nav{
display: flex;
width: 100%;
text-align: right;
margin: 0 10px;
}
.main-nav__items{
display: flex;
margin:8px;
padding:8px;
list-style: none;
}
.main-nav__item{
display: inline-block;
}
.main-nav__social{
display:block;
width: 35px;
height: 35px;
margin-left: 10px;
padding: 4px;
}
#main-slider {
width: 100%;
height: 528px;
/* border-radius: 0% 0% 50% 50% / 0% 0% 20% 20%; */
border-bottom-right-radius: 50% 25%;
border-bottom-left-radius: 50% 25%;
position: relative;
}
/* menu icon */
.main .menu-icon {
cursor: pointer;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.main .menu-icon .nav-icon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}
.main .menu-icon .nav-icon:before,
.main .menu-icon .nav-icon:after {
background: #333;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.main .menu-icon .nav-icon:before {
top: 5px;
}
.main .menu-icon .nav-icon:after {
top: -5px;
}
/* menu btn */
.main .menu-btn {
display: none;
}
.main .menu-btn:checked ~ .menu {
/* max-height: 240px; */
display: block;
}
.main .menu-btn:checked ~ .menu-icon .nav-icon {
background: transparent;
}
.main .menu-btn:checked ~ .menu-icon .nav-icon:before {
transform: rotate(-45deg);
top:0;
}
.main .menu-btn:checked ~ .menu-icon .nav-icon:after {
transform: rotate(45deg);
top:0;
}
#media (min-width: 48em) {
.main li a {
padding: 20px 30px;
}
.main .menu {
clear: none;
float: right;
max-height: none;
}
}
/* start update */
main {display: flex;position: relative;}
main .main {
background: #fff;
order: 2;
padding-top: 15px;
}
main .main .menu {
transition: all .3s ease-in-out;
width: 0;
overflow: hidden;
margin: 0;
padding: 0;
text-align: center;
}
main .main .menu-icon {
position: absolute;
right: 0;
top: 0;
z-index: 9;
}
main .main .menu-btn:checked ~ .menu {
width: 200px;
font-size: 14px;
opacity: 1;
padding-left: 25px;
}
/* end update */
<header class="main-header">
<div>
<a href="index.html" class="main-header__brand">
uHost
</a></div>
<nav class="main-nav">
<div class=main-nav__searchbar_container><input type="text" placeholder="Search" class="main-nav__searchbar">
<button class="icon"><i class="fas fa-search" aria-hidden="true"></i></button>
</div>
<ul class="main-nav__items">
<li class="main-nav__item">
<img class="main-nav__social" src="navbar-icons/social-media__icons/facebook.svg" alt="facebook">
</li>
<li class="main-nav__item">
<img class="main-nav__social" src="navbar-icons/social-media__icons/instagram-bosquejado.svg" alt="instagram">
</li>
</ul>
</nav>
</header>
<main>
<div class="main">
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn">
<span class="nav-icon"></span>
</label>
<ul class="menu">
<li>Test1</li>
<li>Test2</li>
<li>Test3</li>
</ul>
</div>
<section>
<div class="slider-wrapper">
<img id="main-slider" src="https://via.placeholder.com/1365x528?text=Slider">
</div>
</section>
</main>

In-order to do this, you will need to make an outer container.
For example:
<nav id="outer-nav"></nav>
<div id="container">
<div class="slider"></div>
<div id="hamburger-menu">
<div id="hamburger-menu-container">
<div id="hamburger-menu-items">
<ul>
<li>etc</li>
</ul>
</div>
</div>
</div>
</div>
Now that we have the outer container, we can create the CSS to look something like this:
#container {
position:relative;
min-height: 800px;
}
#hamburger-menu {
position:absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
#hamburger-menu-container {
position: relative;
}
The hamburger menu will now stretch the whole distance allowed by the header. And as you add more contents inside the hamburger menu, you can use absolute positioning to place them in different areas of the menu.
For example:
#hamburger-menu-items {
position: absolute;
top: 100px;
}
#hamburger-something-else {
position: absolute;
bottom: 100px;
}
I haven't tested this completely, but should work. Let me know if otherwise :)

Related

Div moves over other one on diferent device scales

So I have this problem, I have Static web page, and i have header section and few others.
But currently right now. Whatever section i set to be under the header section, its just move over the header.
This is first time this is happening, and i cant reslove it.
On first i tought its problem in browser, but it is same on every one that i tried.
I think it is problem in the image on header section so i placed it above the txt section on the header, but section below header stil overlaps on the header.
Soo I double checked all code on header and I think there was nothing wrong that
could cause this.
header {
margin: auto;
height: 100vh;
}
.navigation-menu {
z-index: 10000;
display: flex;
align-items: center;
background: #fff;
box-shadow: 0 1px 1px #333;
justify-content: space-between;
position: fixed;
width: 100%;
left: 0;
top: 0;
padding: 20px 20px;
}
.navigation-menu nav ul {
word-spacing: 10px;
}
.navigation-menu nav ul li {
list-style-type: none;
display: inline-block;
}
.navigation-menu nav ul li a {
font-size: 19px;
}
/*
===== Hamburger Menu =====
*/
.navigation-menu .hamburger {
padding: 5px;
position: relative;
display: none;
cursor: pointer;
right: 40px;
border: none;
background: none;
outline: none;
appearance: none;
}
.navigation-menu .hamburger .bar {
transition: .3s ease all;
position: relative;
display: block;
margin-bottom: 5px;
width: 30px;
height: 3px;
background: #333;
border-radius: 26px;
}
.hamburger.is-active .bar:nth-last-child(1) {
transform: rotate(-45deg) translate(4px, -5px);
}
.hamburger.is-active .bar:nth-last-child(2) {
transform: translateX(-10px);
opacity: 0;
}
.hamburger.is-active .bar:nth-last-child(3) {
transform: rotate(45deg) translate(6px, 8px);
}
.mobile-menu {
transition: .3s ease all;
transform: translateX(100%);
position: fixed;
display: none;
align-items: center;
justify-content: space-around;
left: 0;
top: 0;
width: 100%;
padding-top: 120px;
height: 100vh;
z-index: 2;
background: #fff;
}
.mobile-menu.menu-show {
transform: translateX(0%);
}
.mobile-menu ul {
word-spacing: 10px;
}
.mobile-menu ul li {
list-style-type: none;
}
.mobile-menu ul li a {
font-family: 'Playfair Display', serif;
margin-bottom: 5px;
transition: .3s ease all;
font-size: 45px;
}
.mobile-menu ul li a:hover {
color: red;
}
#media (max-width:533px) {
.navigation-menu nav {
display: none;
}
.navigation-menu .hamburger {
display: block;
}
.mobile-menu {
display: flex;
}
}
/*
===== Hamburger Menu =====
*/
.heading__container {
position: relative;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
height: 100vh;
}
.heading__content {
position: relative;
margin: 6%;
display: block;
}
.heading__title h1{
font-weight: 900;
text-transform: uppercase;
font-size: 55px;
}
.heading__title h1 span {
color: red;
}
.heading__subtitle p{
font-size: 22px;
}
.heading__subtitle {
max-width: 600px;
width: 100%;
}
.heading__image {
padding: 1em;
position: relative;
text-align: center;
}
.heading__image img {
max-width: 400px;
width: 100%;
}
.heading__button-box .btn__read {
background: red;
border: solid 1px red;
}
.heading__button-box .btn__read a {
color: #fff;
}
.heading__button-box .btn__react {
position: relative;
}
.heading__button-box .btn__react::before {
position: absolute;
content: '';
left: 0;
bottom: 0;
background: red;
z-index: -1;
height: 0;
transition: .3s ease all;
width: 100%;
}
.heading__button-box .btn__react:hover::before {
height: 100%;
}
.heading__button-box button {
margin-bottom: 1%;
margin-right: 5%;
}
.heading__button-box .btn__react a {
transition: .3s ease all;
}
.heading__button-box .btn__react:hover {
border: solid 1px red;
}
.heading__button-box .btn__react:hover a {
color: #fff;
}
.heading__button-box .btn__react {
border: solid 1px red;
}
.h__wrapper {
margin-top: 50px;
}
.h__wrapper .h__button {
display: inline-block;
overflow: hidden;
height: 60px;
width: 60px;
float: left;
border-radius: 50px;
cursor: pointer;
margin: 10px 5px;
transition: .3s ease all;
box-shadow: 0 2px 12px #333;
}
.h__wrapper .h__button:hover {
width: 200px;
}
.h__wrapper .h__button .icon {
height: 60px;
width: 60px;
transition: .3s ease all;
border-radius: 50px;
text-align: center;
line-height: 60px;
box-sizing: border-box;
display: inline-block;
}
.h__wrapper .h__button .icon i {
font-size: 25px;
line-height: 60px;
}
.h__wrapper .h__button span {
font-size: 20px;
line-height: 60px;
margin-left: 10px;
font-weight: 500;
}
.h__wrapper .h__button:nth-child(1) .icon {
background: #fff;
}
.h__wrapper .h__button:nth-child(1):hover .icon {
background: rgb(126, 168, 245);
}
.h__wrapper .h__button:nth-child(1):hover .icon i{
color: #fff;
}
.h__wrapper .h__button:nth-child(2) .icon {
background: #fff;
}
.h__wrapper .h__button:nth-child(2):hover .icon {
background: rgb(214, 146, 20);
}
.h__wrapper .h__button:nth-child(2):hover .icon i{
color: #fff;
}
.h__wrapper .h__button:nth-child(3) .icon {
background: #fff;
}
.h__wrapper .h__button:nth-child(3):hover .icon {
background: #333;
}
.h__wrapper .h__button:nth-child(3):hover .icon i{
color: #fff;
}
<header>
<div class="navigation-menu">
<img src="../assets/images/logo/Anima.png" alt="">
<nav>
<ul>
<li>Home</li>
<li>Services</li>
<li>About</li>
<li>Works</li>
<li>Projects</li>
</ul>
</nav>
<div class="hamburger">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
</div>
<nav class="mobile-menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Works</li>
<li>Projects</li>
</ul>
</nav>
<section class="heading__container">
<div class="heading__content">
<div class="heading__title">
<h1><span>Emanuel</span> <br> Rajic</h1>
</div>
<div class="heading__subtitle">
<p>I am 16 years old Front-end developer and CS Student</p>
</div>
<div class="heading__button-box">
<button class="btn__read">Read More</button>
<button class="btn__contact btn__react">Get In Touch</button>
</div>
<div class="h__wrapper">
<div class="h__button">
<div class="icon"><i class="fab fa-twitter"></i></div>
<span>Twitter</span>
</div>
<div class="h__button">
<div class="icon"><i class="fab fa-instagram"></i></div>
<span>Instagram</span>
</div>
<div class="h__button">
<div class="icon"><i class="fab fa-github"></i></div>
<span>Github</span>
</div>
</div>
</div>
<div class="heading__image">
<img src="../assets/images/header/valentin-salja-0aX51h4WvAk-unsplash.jpg">
</div>
</section>
</header>
A combination of z-index:10000, which will give this element priority over everything (so being on top all the time), and position:fixed, which will make that element have a fixed position in the said place no matter the scrolling are, the culprits. Removing those two CSS properties would fix your "issue".

How to align Hamburger menu items?

I have certain menu items in Navbar. It converts to Hamburger when rendered in mobile view thus its responsive. The items in Hamburger menu doesn't align properly. Following is the code reference
body {
margin: 0;
font-family: Helvetica, sans-serif;
background-color: #f4f4f4;
}
a {
color: #000;
}
.header {
background-color: #fff;
box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1);
position: fixed;
width: 100%;
z-index: 3;
}
.header ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
background-color: #fff;
}
.header li a {
display: block;
padding: 20px 20px;
border-right: 1px solid #f4f4f4;
text-decoration: none;
}
.header li a:hover,
.header .menu-btn:hover {
background-color: #f4f4f4;
}
.header .logo {
display: block;
float: left;
font-size: 2em;
padding: 10px 20px;
text-decoration: none;
}
.header .menu {
clear: both;
max-height: 0;
transition: max-height 0.2s ease-out;
}
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.header .menu-icon .navicon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background 0.2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #333;
content: "";
display: block;
height: 100%;
position: absolute;
transition: all 0.2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
.header .menu-btn {
display: none;
}
.header .menu-btn:checked~.menu {
max-height: 240px;
}
.header .menu-btn:checked~.menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked~.menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked~.menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:after {
top: 0;
}
.menu-search {
display: flex;
flex-wrap: wrap;
float: right;
}
.search-box h5 {
color: red;
}
/* 48em = 768px */
#media (min-width: 52em) {
.header li {
float: left;
}
.header li a {
padding: 20px 30px;
}
.header .menu-search .menu-box .menu {
clear: none;
text-align: left;
max-height: none;
}
.header .menu-icon {
display: none;
}
.menu {
float: left;
}
}
<header class="header">
Celebyte
<div class="menu-search">
<span class="search-box">
<h5>Search Box</h5>
</span>
<span class="menu-box">
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"
><span class="navicon"></span
></label>
<ul class="menu">
<li>Celebyte Gifting</li>
<li>Track Order</li>
<li>All Categories</li>
<li>Login</li>
</ul>
</span>
</div>
</header>
As seen above I wanted SearchBox and MenuItems to be in one row, thus used flex, but, even the hamburger items also getting the above property. My intention is to align Hamburger items to left. So what could be the best possible solution?
Codesandbox link: https://codesandbox.io/s/vibrant-night-r7p4e
body {
margin: 0;
font-family: Helvetica, sans-serif;
background-color: #f4f4f4;
}
a {
color: #000;
}
.header {
background-color: #fff;
box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, 0.1);
position: fixed;
width: 100%;
z-index: 3;
}
.header ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
background-color: #fff;
}
.header li a {
display: block;
padding: 20px 20px;
border-right: 1px solid #f4f4f4;
text-decoration: none;
}
.header li a:hover,
.header .menu-btn:hover {
background-color: #f4f4f4;
}
.header .logo {
display: block;
float: left;
font-size: 2em;
padding: 10px 20px;
text-decoration: none;
}
.header .menu {
clear: both;
max-height: 0;
transition: max-height 0.2s ease-out;
}
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.header .menu-icon .navicon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background 0.2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #333;
content: "";
display: block;
height: 100%;
position: absolute;
transition: all 0.2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
.header .menu-btn {
display: none;
}
.header .menu-btn:checked~.menu {
max-height: 240px;
}
.header .menu-btn:checked~.menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked~.menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked~.menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:after {
top: 0;
}
.menu-search {
display: flex;
flex-wrap: wrap;
width: calc(100% - 166.297px);
}
.search-box h5 {
color: red;
}
/* 48em = 768px */
#media (min-width: 52em) {
.header li {
float: left;
}
.header li a {
padding: 20px 30px;
}
.header .menu-search .menu-box .menu {
clear: none;
text-align: left;
max-height: none;
}
.header .menu-icon {
display: none;
}
.menu {
float: left;
}
}
.search-box {
position: absolute;
right: 10px;
}
<header class="header">
Celebyte
<div class="menu-search">
<span class="menu-box">
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<ul class="menu">
<li>Celebyte Gifting</li>
<li>Track Order</li>
<li>All Categories</li>
<li>Login</li>
</ul>
</span>
<span class="search-box">
<h5>Search Box</h5>
</span>
</div>
</header>

How to align the menu to the right side of the desktop?

I am have a menu for my website and which is currently align on the left side of the browser. I am try to align on the right side of the browser.
here is the demo: here
what I want is just put the hole menu and align it on the right side of the browser screen. currently its showing on the left side.
trying to do:https://i.stack.imgur.com/D0y00.png
html code:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<header>
<span class="toggle-button">
<div class="menu-bar menu-bar-top"></div>
<div class="menu-bar menu-bar-middle"></div>
<div class="menu-bar menu-bar-bottom"></div>
</span>
<div class="menu-wrap">
<div class="menu-sidebar">
<ul class="menu">
<li>Home</li>
<li class="children">News
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li class="children">Contact
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li class="children">About
<span class="arrow"></span>
<ul class="child-menu ">
<li>Link 1</li>
<li>Link 2</li>
<li>link 3</li>
</ul>
</li>
<li>FAQ</li>
<li>Services</li>
</ul>
</div>
</div>
</header>
<div class="wrapper" style="background-color:;padding:15px;">
<section class="text" style="background-color:;">
<h2 class="heading" id="headings" style="background-color:;text-align:center;">Three Line Menu & CSS Transitions</h2>
<p class="buttons" style="min-width: 200px;margin:auto;background-color:;text-align:center;">
Learn More
</p>
</section>
</div>
CSS:
html {
background: url(https://s33.postimg.cc/tm1vd9yy7/Background_2.jpg);
background-attachment:fixed;
background-repeat: no-repeat;
background-size: cover;
}
.btn_one {
text-decoration: none;
color: white;
font-weight: 100;
border: 1px #fbbc05 solid;
padding: 1em 3em;
border-radius: 100px;
}
a {
text-decoration: none;
}
ul {
padding-left: 0;
}
li {
list-style: none;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Montserrat', Arial, serif;
}
::selection {
background-color: #EBEBF2;
color: #83828D;
}
/* ==================================== */
/* Navigaton Menu */
/* ==================================== */
.menu-wrap {
background-color: #625871;
position: fixed;
top: 0;
height: 100%;
width: 280px;
margin-left: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
}
.menu-show {
margin-left: 0;
box-shadow: 4px 2px 15px 1px #262424;
}
.menu-sidebar {
margin: 75px 0 80px 10px;
position: relative;
top: 70px;
}
.menu-sidebar li {
padding: 18px 22px 0;
}
.menu-sidebar li > a {
color: #f3f3f3;
font-size: 1.18em;
position: relative;
}
.menu-sidebar li > a::after {
content: "";
display: block;
height: 0.15em;
position: absolute;
top: 100%;
width: 100%;
left: 50%;
transform: translate(-50%);
background-image: linear-gradient(to right, transparent 50.3%, #FFFA3B 50.3%);
transition: background-position .2s .1s ease-out;
background-size: 200% auto;
}
.menu-sidebar li > a:hover::after {
background-position: -100% 0;
}
.menu-sidebar .children {
position: relative;
}
.menu-sidebar .children .child-menu {
display: none;
}
.arrow::after {
content: "\f107";
font-family: 'FontAwesome';
padding: 10px;
color: #FFFA3B;
position: relative;
}
.arrow:hover::after {
cursor: pointer;
color: #fff;
}
.arrow:active::after {
top: 2px;
}
/*Hamburger Button*/
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
top: 50px;
left: 40px;
padding: 4px;
transition: .25s;
z-index: 15;
}
.toggle-button:hover {
cursor: pointer;
}
.toggle-button .menu-bar {
position: absolute;
border-radius: 2px;
transition: .5s;
}
.toggle-button .menu-bar-top {
border: 4px solid #fff;
border-bottom: none;
top: 0;
width: 80%;
}
.toggle-button .menu-bar-middle {
height: 4px;
background-color: #fff;
margin-top: 7px;
margin-bottom: 7px;
width: 40%;
top: 4px;
}
.toggle-button .menu-bar-bottom {
border: 4px solid #fff;
border-top: none;
top: 22px;
width: 60%;
}
.toggle-button:hover div
{
width: 80%;
}
.button-open {
left: 25px;
}
.button-open .menu-bar-top {
border-color: #fff;
transform: rotate(45deg) translate(8px, 8px);
transition: .5s;
}
.button-open .menu-bar-middle {
background-color: #fff;
transform: translate(230px);
transition: .1s ease-in;
opacity: 0;
}
.button-open .menu-bar-bottom {
border-color: #fff;
transform: rotate(-45deg) translate(7px, -7px);
transition: .5s;
}
/* Text Block */
.wrapper {
width: 40%;
margin: 100px auto 0;
color: #83828D;
}
.wrapper .text {
padding: 30px;
}
.wrapper .text .heading {
margin-bottom: 40px;
font-size: 2em;
color:#fff;
}
.wrapper .text p {
line-height: 1.6em;
}
.wrapper .text .buttons {
margin-top: 40px;
}
/* Buttons */
.wrapper .buttons .button {
display: inline-block;
margin-right: 20px;
padding: 20px 25px;
border-radius: 2em;
background-color: #70CE64;
color: #fff;
font-size: .9em;
font-weight: 700;
transition: background-color .3s;
}
.wrapper .buttons .button-secondary {
background-color: #FF6746;
}
.wrapper .buttons .button-primary:hover {
background-color: #84D07A;
}
.wrapper .buttons .button-secondary:hover {
background-color: #FF7D60;
}
/*Active state for the buttons*/
.wrapper .buttons .button-primary:active {
background-color: #70CE64;
}
.wrapper .buttons .button-secondary:active {
background-color: #FF6746;
}
/*Icons*/
.wrapper .buttons .button span {
position: relative;
display: inline-block;
padding-right: 20px;
}
.wrapper .buttons .button span::after {
position: absolute;
font-family: "FontAwesome";
right: -3px;
font-size: 14px;
top: 0;
transition: top .3s, right .3s;
}
.wrapper .buttons .button-primary span::after {
content: "\f019";
}
.wrapper .buttons .button-secondary span::after {
content: "\f178";
}
/*Slight icons animation*/
.wrapper .buttons .button-primary:hover span::after {
top: 4px;
}
.wrapper .buttons .button-secondary:hover span::after {
right: -6px;
}
#media screen and (max-width: 480px) {
#headings{
margin-bottom:20px;
font-size: 18px;
color:#fff;
}
.btn_one {
text-decoration: none;
color: #fff;
font-size:12px;
font-weight: 100;
border: 1px #fbbc05 solid;
padding: 8px 23px;
border-radius: 100px;
}
ul {
padding-left: 35px;
}
.menu-sidebar li
{
padding:0;
}
.menu-wrap {
width: 200px;
}
}
SCRIPT:
$(document).ready(function() {
var $toggleButton = $('.toggle-button'),
$menuWrap = $('.menu-wrap'),
$sidebarArrow = $('.arrow');
// Hamburger button
$toggleButton.on('click', function() {
$(this).toggleClass('button-open');
$menuWrap.toggleClass('menu-show');
});
// Sidebar navigation arrows
$sidebarArrow.click(function() {
$(this).next().slideToggle(300);
});
});
Here is the source code for reference: https://nofile.io/f/9bKHsuOoUza/source_code_new.zip
Can anybody guide me? Any input is appreciated.
Thank you so much.
change the toggle button to:
default:
.toggle-button {
position: fixed;
width: 44px;
height: 40px;
top: 50px;
left: auto;
padding: 4px;
transition: .25s;
z-index: 15;
right: 40px;
}
open:
.button-open {
left: auto;
right: 25px;
}
then change the menu to:
closed:
.menu-wrap {
background-color: #00000030;
position: fixed;
top: 0;
height: 100%;
width: 240px;
margin-left: 0;
right: -280px;
font-size: 1em;
font-weight: 700;
overflow: auto;
transition: .25s;
z-index: 10;
left: auto;
}
open:
.menu-show {
left: auto;
right: 0;
margin-left: 0;
box-shadow: 4px 2px 15px 1px #080707;
}
easy as that!

Responsive Hamburger Nav Border

I'm creating this navigation, learning how to develop responsive navigation menus. And I can't get the a tag in the menu to go full height leaving this 5px margin between the nav and the border when you hover over the buttons. I've spent quite some time trying to figure this out and googling, however I think I need someones help.
Notice in this image when I hover over the a link theres about 5px of margin between the bottom of the of a link and the nav. Example of Problem
body {
margin: 0;
font-family: Helvetica, sans-serif;
background-color: #f4f4f4;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
a {
color: #000;
}
.header {
background-color: #fff;
box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, .1);
position: fixed;
width: 100%;
z-index: 3;
}
.header ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
background-color: #fff;
}
.header li a {
display: block;
padding: 20px 20px;
border-right: 1px solid #f4f4f4;
text-decoration: none;
}
.header li a:hover,
.header .menu-btn:hover {
background-color: #f4f4f4;
}
.header .logo {
display: block;
float: left;
font-size: 2em;
padding: 10px 20px;
text-decoration: none;
}
/* menu */
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
}
/* menu icon */
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.header .menu-icon .navicon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #333;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
/* menu btn */
.header .menu-btn {
display: none;
}
.header .menu-btn:checked~.menu {
max-height: 240px;
}
.header .menu-btn:checked~.menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked~.menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked~.menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:after {
top: 0;
}
/* 48em = 768px */
#media (min-width: 48em) {
.header li {
float: left;
}
.header li a {
padding: 20px 30px;
}
.header .menu {
clear: none;
float: right;
max-height: none;
}
.header .menu-icon {
display: none;
}
}
<header class="header">
<div class="container">
Test Navigation
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<!-- Main Navigation -->
<ul class="menu">
<li>Our Work</li>
<li>About</li>
<li>Careers</li>
<li>Contact</li>
</ul>
</div>
</header>
.header li a {
display: block;
padding: 20px 25px; /*increase the left padding by 5px */
border-right: 1px solid #f4f4f4;
text-decoration: none;
}
Do you want to reduce the padding of the "a" tag? If so change the padding as below -
.header li a {
display: block;
padding: 5px 5px;
border-right: 1px solid #f4f4f4;
text-decoration: none;
}
Otherwise let us know your query clearly with a picture as what change are you expecting. It is really difficult to figure out exactly what you want..
body {
margin: 0;
font-family: Helvetica, sans-serif;
background-color: #f4f4f4;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
a {
color: #000;
}
.header {
background-color: #fff;
box-shadow: 1px 1px 4px 0 rgba(0, 0, 0, .1);
position: fixed;
width: 100%;
z-index: 3;
}
.header ul {
margin: 0;
padding: 0;
list-style: none;
overflow: hidden;
background-color: #fff;
}
.header li a {
display: block;
padding: 5px 5px;
border-right: 1px solid #f4f4f4;
text-decoration: none;
}
.header li a:hover,
.header .menu-btn:hover {
background-color: #f4f4f4;
}
.header .logo {
display: block;
float: left;
font-size: 2em;
padding: 10px 20px;
text-decoration: none;
}
/* menu */
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
}
/* menu icon */
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.header .menu-icon .navicon {
background: #333;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #333;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
/* menu btn */
.header .menu-btn {
display: none;
}
.header .menu-btn:checked~.menu {
max-height: 240px;
}
.header .menu-btn:checked~.menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked~.menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked~.menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked~.menu-icon:not(.steps) .navicon:after {
top: 0;
}
/* 48em = 768px */
#media (min-width: 48em) {
.header li {
float: left;
}
.header li a {
padding: 20px 30px;
}
.header .menu {
clear: none;
float: right;
max-height: none;
}
.header .menu-icon {
display: none;
}
}
<header class="header">
<div class="container">
Test Navigation
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<!-- Main Navigation -->
<ul class="menu">
<li>Our Work</li>
<li>About</li>
<li>Careers</li>
<li>Contact</li>
</ul>
</div>
</header>

Bottom border on menu extends too far on hoover

I have created a responsive pure css menu on my page which works great except for the hover. On hover I need it to draw a magenta line under the menu text. This works already but the line extends too far past the end of the word. It should only underline the word. I had this working previously so I know it can be done but that was with a different menu and I achieved it through random bashing of keys so I don't know how to repeat it.
This might be a duplicate. I noticed two other related posts but I was not able to get their solutions to work so either it's a different problem or I'm not figuring out how to apply the changes to my code correctly.
This is what it currently looks like:
HTML
#{
ViewBag.Title = "_Layout";
}
<link href="~/Content/Site.css" rel="stylesheet" />
<div class="wrapper">
<header class="header">
<a href="/" class="logo">
<img src="~/Images/companylogo.png" />
</a>
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<ul class="menu">
<li>About</li>
<li>Residential & Business</li>
<li>My Account Details</li>
<li>FAQ</li>
<li>Contact</li>
</ul>
</header>
<!--End of code for responsive menu-->
<!--HEADER END-->
<div class="page-content">
<div class="cloud1">
<img src="~/Images/cloud1.png" />
</div>
<div class="cloud2">
<img src="~/Images/cloud2.png" />
</div>
<div class="cloud3">
<img src="~/Images/cloud3.png" />
</div>
<div class="cloud4">
<img src="~/Images/cloud4.png" />
</div>
<!--CONTENT START-->
<div class="box">
#RenderBody()
</div>
<!--CONTENT END-->
</div>
<!--FOOTER START-->
<div class="bottom">
<div class="padt120">
<img src="~/Images/about-buildings.png" alt="Buildings" class="buildings" />
<div class="grass"></div>
</div>
<footer class="padtb30">
<span class="copyright">
<small class="lightgrey-text">
© Copyright 2016. All Rights Reserved. SomeCompany Inc. Privacy Policy
</small>
</span>
</footer>
</div>
</div>
CSS
#font-face {
font-family: 'HelveticaNeue-Thin';
src: url('../Resources/HelveticaNeue-Thin.woff') format('woff');
}
#font-face {
font-family: 'HelveticaNeue';
src: url('../Resources/HelveticaNeue.woff') format('woff');
}
#font-face {
font-family: 'fontawesome-webfont';
src: url('../Resources/fontawesome-webfont.ttf') format('truetype');
}
#keyframes cloud1 {
0% {
left: -488px;
top: 100px;
}
100% {
left: 100%;
top: 100px;
}
}
#keyframes cloud2 {
0% {
left: -215px;
top: 200px;
}
100% {
left: 100%;
top: 200px;
}
}
#keyframes cloud3 {
0% {
left: -421px;
top: 300px;
}
100% {
left: 100%;
top: 300px;
}
}
#keyframes cloud4 {
0% {
left: -359px;
top: 400px;
}
100% {
left: 100%;
top: 400px;
}
}
body {
padding-top: 50px;
padding-bottom: 20px;
background-image: linear-gradient(#B2D2EA, #ffffff);
overflow-x: hidden;
}
.header {
background-color: #fff;
position: absolute;
display: table;
top: 0;
left: 0;
width: 100%;
height: 80px;
z-index: 3;
font-family: HelveticaNeue-Thin;
font-size: medium;
}
.header ul {
align-self: center;
height: auto;
margin: 0;
padding: 8px 5%;
list-style: none;
overflow: hidden;
background-color: #fff;
}
.heading li {
display: inline;
padding: 5px;
}
.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px;
font-family: HelveticaNeue-Thin;
border-bottom: 3px solid transparent;
transition: 0.5s ease;
white-space: nowrap;
color: #171581;
}
.header li a:hover {
color: #D60053;
border-bottom: 3px solid #D60053;
border-bottom-width: 2px;
padding-bottom: 2px;
width: auto;
}
a::after {
display: block;
content: attr(title);
font-family: HelveticaNeue-Thin;
height: 1px;
color: transparent;
overflow: hidden;
visibility: hidden;
margin-bottom: -1px;
}
#about {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}
#residential {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}
#myaccountdetails {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}
#faq {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}
#contactus {
padding-left: 0px;
padding-right: 0px;
text-align: center;
width: auto;
}
.header .logo {
display: table-cell;
height: 100%;
padding-left: 5%;
vertical-align: middle;
}
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
}
/*End of code added for menu*/
/*Style menu icon*/
.header .menu-icon {
cursor: pointer;
display: inline-block;
float: right;
padding: 28px 20px;
position: relative;
user-select: none;
}
.header .menu-icon .navicon {
background: #80BD01;
display: block;
height: 2px;
position: relative;
transition: background .2s ease-out;
width: 18px;
}
.header .menu-icon .navicon:before,
.header .menu-icon .navicon:after {
background: #80BD01;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
.header .menu-icon .navicon:before {
top: 5px;
}
.header .menu-icon .navicon:after {
top: -5px;
}
/*End of style for men icon*/
/*Icon and menu animations when the checkbox is clicked*/
.header .menu-btn {
display: none;
}
.header .menu-btn:checked ~ .menu {
max-height: 240px;
}
.header .menu-btn:checked ~ .menu-icon .navicon {
background: transparent;
}
.header .menu-btn:checked ~ .menu-icon .navicon:before {
transform: rotate(-45deg);
}
.header .menu-btn:checked ~ .menu-icon .navicon:after {
transform: rotate(45deg);
}
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:before,
.header .menu-btn:checked ~ .menu-icon:not(.steps) .navicon:after {
top: 0;
}
/*End of menu and icon animations*/
/*Show the horizontal menu items for larger browser widths by default*/
#media (min-width: 48em) {
.header li {
float: left;
}
.header li a {
margin: 0;
padding: 20px 30px;
}
.header .menu {
clear: none;
float: right;
max-height: none;
}
.header .menu-icon {
display: none;
}
}
/*End of menu items for large browser widths*/
.page-content {
font-family: HelveticaNeue;
margin-left: 10%;
margin-right: 10%;
padding-top: 50px;
padding-bottom: 100px;
max-width: 100%;
height: auto;
text-align: center;
}
.cloud1 {
animation-name: cloud1;
animation-duration: 25s;
animation-iteration-count: infinite;
position: absolute;
top: 100px;
left: -488px;
z-index: -1;
}
.cloud2 {
animation-name: cloud2;
animation-duration: 25s;
animation-delay: 10s;
animation-iteration-count: infinite;
position: absolute;
top: 200px;
left: -215px;
z-index: -1;
}
.cloud3 {
animation-name: cloud3;
animation-duration: 20s;
animation-delay: 7s;
animation-iteration-count: infinite;
position: absolute;
top: 300px;
left: -421px;
z-index: -1;
}
.cloud4 {
animation-name: cloud4;
animation-duration: 30s;
animation-delay: 10s;
animation-iteration-count: infinite;
position: absolute;
top: 400px;
left: -359px;
z-index: -1;
}
.box {
background-color: #F28B20;
border-radius: 5px;
height: auto;
margin-bottom: 150px;
width: 80%;
display: inline-block;
box-shadow: 10px 10px 5px #888888;
background-image: url("../Images/logo_faded_background-2.png");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.bottom {
position: relative;
height: auto;
width: 100%;
}
.grass {
height: 20px;
width: 100%;
background-color: #80BD01;
}
.padtb30 {
width: 100%;
position: absolute;
bottom: 0;
height: 80px;
line-height: 80px;
background-color: #ffffff;
text-align: center;
}
.buildings {
display: block;
margin: 0 auto;
}
.padt120 {
position: absolute;
width: 100%;
height: 100px;
bottom: 100px;
background-image: url("../Images/backcity.png");
background-position: center;
}
.copyright {
font-family: HelveticaNeue;
}
Here's a fiddle for the user who requested it.
http://jsfiddle.net/kd7nv4vb
I changed your HTML and CSS a bit and came up with this:
HTML: Added <span>in <a>:
<li>
<a href="#about">
<span>About</span>
</a>
</li>
CSS:
.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px;
font-family: HelveticaNeue-Thin;
white-space: nowrap;
color: #171581;
}
.header li a span {
transition: 0.5s ease;
border-bottom: 3px solid transparent;
}
.header li a:hover span {
color: #D60053;
border-bottom: 3px solid #D60053;
border-bottom-width: 2px;
padding-bottom: 2px;
width: auto;
}
Previous (your code):
.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px;
font-family: HelveticaNeue-Thin;
border-bottom: 3px solid transparent;
transition: 0.5s ease;
white-space: nowrap;
color: #171581;
}
.header li a:hover {
color: #D60053;
border-bottom: 3px solid #D60053;
border-bottom-width: 2px;
padding-bottom: 2px;
width: auto;
}
You're issue was with the padding on the link elements.
.header li a {
text-decoration: none;
display: inline-block;
height: 20px;
padding: 8px 8px 8px 8px; /*This was where your problem was*/
font-family: HelveticaNeue-Thin;
border-bottom: 3px solid transparent;
transition: 0.5s ease;
white-space: nowrap;
color: #171581;
}
Borders will always fill the space of the container for its respective element. If you switch that line of padding to remove the left and right padding, you should end up with what you want.
padding: 8px 0px 8px 0px;
Here is a working example.
If this works, please don't forget to mark this as the correct answer so anyone else with this problem will see this answer.