I have a fixed header with a <nav> into it. The problem is that I tried a lot of things, but my elements don't vertically align on middle. I cannot use line-height because it depends on screen resolution.
CSS
header {
width: 100%;
height: 15%;
background-color: rgba(30, 30, 30, 0.75);
color: white;
font-family: 'Roboto', sans-serif;
font-weight: bold;
text-align: center;
position: fixed;
text-transform: uppercase;
overflow: hidden;
}
header nav {
text-align: center;
display: inline-block;
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: 0;
}
header nav a {
/*line-height: 6;*/
color: white;
padding: 14px 16px;
text-align: center;
display: inline;
text-decoration: none;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
HTML
<header>
<div>
<nav>
<a class="active" href="">Home</a>
News
Info
Contact
</nav>
</div>
</header>
Demo: http://jsfiddle.net/JJ8Jc/4082/
You can use display flex method to align elements vertically and/or horizontally
I just added
header nav {
display:flex;
justify-content: center;
align-items: center;
}
so you example now become:
header {
width: 100%;
height: 15%;
background-color: rgba(30, 30, 30, 0.75);
color: white;
font-family: 'Roboto', sans-serif;
font-weight: bold;
text-align: center;
position: fixed;
text-transform: uppercase;
overflow: hidden;
display:flex;
}
header nav {
text-align: center;
display:flex;
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: 0;
justify-content: center;
align-items: center;
}
header nav a {
/*line-height: 6;*/
color: white;
padding: 14px 16px;
text-align: center;
display: inline;
text-decoration: none;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
<header>
<div>
<nav>
<a class="active" href="">Home</a>
News
Info
Contact
</nav>
</div>
</header>
on your .nav css, change top: 0; for top: 50%; then add these lines:
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
and remove bottom: 0;
jsfiddle
Alternatively, you could use padding-bottom and padding-top to increase the header size keeping the content on the middle. Or, yet, let it flex like the other answer has already suggested.
header {
width: 100%;
height: 15%;
background-color: rgba(30, 30, 30, 0.75);
color: white;
font-family: 'Roboto', sans-serif;
font-weight: bold;
text-align: center;
position: fixed;
text-transform: uppercase;
overflow: hidden;
}
header nav {
text-align: center;
display: inline-block;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
right: 0;
left: 0;
margin: 0;
}
header nav a {
/*line-height: 6;*/
color: white;
padding: 14px 16px;
text-align: center;
display: inline;
text-decoration: none;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
<header>
<div>
<nav>
<a class="active" href="">Home</a>
News
Info
Contact
</nav>
</div>
</header>
Related
I'm trying to make a responsive site, in which when the width decreases, my nav-links go out of sight, but there is a ***Horizontal Scroll Bar***, that I want to get rid of. I've viewed other question for this, but none of them helped me.
Any Suggestions?
Thank in advance
HTML
<header class="head">
<nav class="navbar">
<div class="logo">
Krishang Sharma
</div>
<ul class="nav-items">
<li>Work</li>
<li>About</li>
<li>Contact</li>
</ul>
<div class="crossMenu">
<div class="line1"></div>
<div class="line2"></div>
</div>
<!-- Theme Toggle Switch -->
<div class="switch">
<div class="bg">
<div class="circle"></div>
</div>
</div>
</nav>
</header>
CSS
.navbar{
width: 100vw;
height: 10vh;
display: flex;
align-items: center;
font-family: 'Poppins', serif;
justify-content: space-evenly;
box-shadow: 0px 15px 20px #1e1e1e;
}
.logo{
width: 40%;
}
.logo a{
color: white;
transition: 0.3s;
font-size: 1.5rem;
text-decoration: none;
}
.logo a:hover{
transition: 0.3s;
color: #639FAB;
}
.nav-items{
width: 40%;
display: flex;
justify-content: space-around;
}
.nav-items, li a{
align-items: center;
height: 100%;
font-size: 18px;
color: white;
list-style: none;
transition: 0.3s;
text-decoration: none;
}
.nav-items a:hover{
transition: 0.3s;
color: #639FAB;
}
.crossMenu{
cursor: pointer;
display: none;
margin-right: 2%;
}
.line1, .line2{
margin: 4px;
height: 4px;
width: 35px;
transition: 0.5s ease;
border-radius: 25px;
background: #639FAB;
}
.switch{
cursor: pointer;
align-items: center;
}
.bg{
height: 20px;
width: 60px;
background: white;
border-radius: 10px;
transition: 0.5s ease;
}
.circle{
right: 5px;
top: -5px;
width: 30px;
height: 30px;
position: relative;
border-radius: 50%;
transition: 0.5s ease;
background: #639FAB;
}
.circleOn{
background: white;
right: -35px;
transition: 0.5s ease;
}
.bgOn{
transition: 0.5s ease;
background: #639FAB;
}
For Lower Resoultion
.nav-items{
right: 15%;
position: absolute;
transition: 0.5s ease;
transform: translateX(200%);
}
Add overflow-x: hidden; to the style= attribute of your navbar.
Why You have used transform: translateX(200%); on .nav-items element?. You should remove/add transform: translateX(0); on .nav-items this element. Then Horizontal Scroll Bar will not show
I only want to push dots down on hover not the main content
.links {
margin-top: 2rem;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid red;
padding: 20px 70px;
justify-content: space-evenly;
height: 180px;
transition: all 3s ease-in-out all;
}
a {
margin: 20px;
text-decoration: none;
color: rgb(32, 32, 32);
font-size: 21px;
vertical-align: baseline;
transition: 3s ease-in-out all;
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
a:hover .learnMore {
display: block;
}
/* *this is the hidden part* */
.learnMore {
display: none;
transition: 3s ease-in-out all;
}
/* **__this part needs to be pushed down on hover __** */
.dots {
color: rgb(30, 140, 184);
font-size: 2.3rem;
font-family: soleil, Helvetica, Arial, sans-serif;
transform: translateY(-15px);
}
/*>I dont wanna use opacity**/
<div class="links">
Digital Marketing <div class="learnMore">Learn More</div><div class="dots">...</div>
Security Solutions<div class="learnMore">Learn More</div> <div class="dots">...</div>
Healthcare Technology<div class="learnMore">Learn More</div> <div class="dots">...</div>
Business Process Automation<div class="learnMore">Learn More</div> <div class="dots">...</div>
</div>
*Only dots needs to be pushed down not the text above it *
you have to specify the height property for a tag.
a {
height:100px; /* add this line */
margin: 20px;
text-decoration: none;
color: rgb(32, 32, 32);
font-size: 21px;
vertical-align: baseline;
transition: 3s ease-in-out all;
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.links {
margin-top: 2rem;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid red;
padding: 20px 70px;
justify-content: space-evenly;
height: 180px;
transition: all 3s ease-in-out all;
}
a {
height:100px;
margin: 20px;
text-decoration: none;
color: rgb(32, 32, 32);
font-size: 21px;
vertical-align: baseline;
transition: 3s ease-in-out all;
position: relative;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
a:hover .learnMore {
display: block;
}
/* *this is the hidden part* */
.learnMore {
display: none;
transition: 3s ease-in-out all;
}
/* **__this part needs to be pushed down on hover __** */
.dots {
color: rgb(30, 140, 184);
font-size: 2.3rem;
font-family: soleil, Helvetica, Arial, sans-serif;
transform: translateY(-15px);
}
/*>I dont wanna use opacity**/
<div class="links">
Digital Marketing <div class="learnMore">Learn More</div><div class="dots">...</div>
Security Solutions<div class="learnMore">Learn More</div> <div class="dots">...</div>
Healthcare Technology<div class="learnMore">Learn More</div> <div class="dots">...</div>
Business Process Automation<div class="learnMore">Learn More</div> <div class="dots">...</div>
</div>
Helow Guys, I just created a menu links design by following some tutorial in YT, however, I encountered some error, while hovering the links it goes to the logo image space, making the image logo can't see it clearly. What I want is while hovering the links it creates a padding or margin so that the image logo will not disturb and stay the logo where he is. Here's my code
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.firstNav > a {
position: relative;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: 0.5s;
color: #000;
}
nav:hover a {
transform: scale(1.5);
opacity: .6;
filter: blur(4px);
}
nav .firstNav a:hover {
transform: scale(2);
opacity: 1;
filter: blur(0);
}
nav .firstNav a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #2575aa;
transition: 0.5s;
transform-origin: right;
transform: scaleX(0);
z-index: -1;
}
nav .firstNav a:hover::before{
transition: 0.5s;
transform-origin: left;
transform: scaleX(1);
}
<nav>
<div class="firstNav">
Home
Blog
Portfolio
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
Progress
About
Contact
</div>
</nav>
I think given what you are trying to do it will always invade the space of the logo, so an alternative to Smollet777's answer is that you can adjust its behaviour to push out the items so it wont matter what the width of the text content is.
You can split the nav items in two to keep the logo in a fixed placed and use css transitions to expand the other items like so:
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
width: 800px;
}
.blurLink {
position: relative;
font-family: "Montserrat", sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: font-size 1s, padding 1s;
color: #000;
}
.blurLink:hover {
font-size: 32px;
padding: 0 20px;
background: #2575aa;
}
.navGroup {
width: 40%;
display: flex;
justify-content: flex-end;
align-items: center;
}
.navGroup2 {
width: 40%;
display: flex;
justify-content: flex-start;
align-items: center;
}
<nav>
<div class="firstNav">
<div class="navGroup">
Home
Blog
Portfolio
</div>
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
<div class="navGroup2">
Progress
About
Contact
</div>
</div>
</nav>
You can use element:nth-child(index) to target specific element in CSS.
nav .firstNav a:nth-child(3):hover {
position: relative;
left: -55px;
}
nav .firstNav a:nth-child(5):hover {
position: relative;
right: -55px;
}
.logo {
height: 65px;
width: 65px;
}
.firstNav {
display: flex;
justify-content: center;
align-items: center;
margin-top: 10px;
}
.firstNav>a {
position: relative;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 14px;
text-transform: uppercase;
text-decoration: none;
padding: 0 12px;
transition: 0.5s;
color: #000;
}
nav:hover a {
transform: scale(1.5);
opacity: .6;
filter: blur(4px);
}
nav .firstNav a:hover {
transform: scale(2);
opacity: 1;
filter: blur(0);
}
nav .firstNav a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #2575aa;
transition: 0.5s;
transform-origin: right;
transform: scaleX(0);
z-index: -1;
}
nav .firstNav a:hover::before {
transition: 0.5s;
transform-origin: left;
transform: scaleX(1);
}
<nav>
<div class="firstNav">
Home
Blog
Portfolio
<img src="https://i.stack.imgur.com/JWQJm.png" alt="logo" class="logo">
Progress
About
Contact
</div>
</nav>
Use this and you'll be ok.
.firstNav>a:nth-of-type(3):hover {
transform: translateX(-55px) scale(2);
}
.firstNav>a:nth-of-type(4):hover {
transform: translateX(55px) scale(2);
}
I made several changes to a navigation bar that I had. Since the changes, I cannot get the red "Request Quote" button to vertically align in the middle to line up with the other items in the nav.
What I changed was wrapping the link around the list item so that the whole space would be clickable for the mobile version. Previously, the html was like:
<li>LEARN</li>
and I would use #nav-list li a to call the elements because I didn't assign a class at that point.
Does anyone see what I am doing wrong? I do not want to use position: absolute if possible.
nav {
background: #FFF;
height: 70px;
width: 100%;
max-width: 100%;
box-shadow: 0px 6px 15px -4px rgba(0,0,0,0.12);
position: fixed;
top: 0;
z-index: 999;
box-sizing: border-box;
}
#nav-pop {
float: right;
display: block;
margin-right: 5%;
margin-top: 25px;
transition: ease 0.5s;-webkit-transition: ease 0.5s;
}
#nav-pop.active {
opacity: 1;
background: rgba(0,0,0,0.8);
background: #2f2f2f;
right: 0;
margin-top: 0;
margin-right: 0;
z-index: 999999;
transition: ease 0.6s;-webkit-transition: ease 0.6s;
transform: translateX(0);-webkit-transform: translateX(0);
box-shadow: -9px 0px 9px 1px rgba(0,0,0,.2);
}
.navItem {
display: inline-block;
margin: 0 17px;
vertical-align: top;
}
.navItem:first-child {
margin-left: 0px;
}
.navItem:last-child {
margin-right: 0px;
}
.navItem, #serviceClick {
text-decoration: none;
font-family: 'Muli', sans-serif;
font-size: .9rem;
color: #747678;
letter-spacing: 1px;
vertical-align: top;
transition: all .3s;-webkit-transition: all .3s;
cursor: pointer;
}
.navItem:after, #serviceClick:after {
content: '';
display: block;
width: 0;
margin-top: 6px;
background: #b82222;
height: 2px;
transition: width .3s;
}
.navItem:hover, #serviceClick:hover {
color: #4b4b4b;
transition: all .3s;-webkit-transition: all .3s;
}
.navItem:hover:after, #serviceClick:hover:after {
width: 100%;
transition: width .3s;
}
.navInverse {
padding: 10px 12px;
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.2rem;
color: #FFF;
border: 1px solid #b82222;
background: linear-gradient(to right bottom, #b82222, #a51e1e);
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
}
.navInverse:hover {
background: #b82222;
background: #FFF;
color: #b82222;
}
.navInverse:after {
content: '';
display: none;
width: 0px;
height: 0px;
transition: none;
}
<nav>
<div id="nav-pop">
<ul id="nav-list">
<li>ABOUT</li>
<li id="serviceClick" class="navItem">SOLUTIONS</li>
<li>LEARN</li>
<li>CONTACT</li>
<li>REQUEST QUOTE</li>
</ul>
</div>
</nav>
A revised answer of my previous explantaion, just remove the margin-top in nav-pop and the add:
#nav-list {
display: flex;
align-items: center;
}
See snippet for finished output:
nav {
background: #FFF;
height: 70px;
width: 100%;
max-width: 100%;
box-shadow: 0px 6px 15px -4px rgba(0,0,0,0.12);
position: fixed;
top: 0;
z-index: 999;
box-sizing: border-box;
}
#nav-list {
display: flex;
align-items: center;
}
#nav-pop {
float: right;
display: block;
margin-right: 5%;
margin-top: 15px;
transition: ease 0.5s;-webkit-transition: ease 0.5s;
}
#nav-pop.active {
opacity: 1;
background: rgba(0,0,0,0.8);
background: #2f2f2f;
right: 0;
margin-top: 0;
margin-right: 0;
z-index: 999999;
transition: ease 0.6s;-webkit-transition: ease 0.6s;
transform: translateX(0);-webkit-transform: translateX(0);
box-shadow: -9px 0px 9px 1px rgba(0,0,0,.2);
}
.navItem {
display: inline-block;
margin: 0 17px;
vertical-align: top;
}
.navItem:first-child {
margin-left: 0px;
}
.navItem:last-child {
margin-right: 0px;
}
.navItem, #serviceClick {
text-decoration: none;
font-family: 'Muli', sans-serif;
font-size: .9rem;
color: #747678;
letter-spacing: 1px;
vertical-align: top;
transition: all .3s;-webkit-transition: all .3s;
cursor: pointer;
}
.navItem:after, #serviceClick:after {
content: '';
display: block;
width: 0;
margin-top: 6px;
background: #b82222;
height: 2px;
transition: width .3s;
}
.navItem:hover, #serviceClick:hover {
color: #4b4b4b;
transition: all .3s;-webkit-transition: all .3s;
}
.navItem:hover:after, #serviceClick:hover:after {
width: 100%;
transition: width .3s;
}
.navInverse {
padding: 10px 12px;
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.2rem;
color: #FFF;
border: 1px solid #b82222;
background: linear-gradient(to right bottom, #b82222, #a51e1e);
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
}
.navInverse:hover {
background: #b82222;
background: #FFF;
color: #b82222;
}
.navInverse:after {
content: '';
display: none;
width: 0px;
height: 0px;
transition: none;
}
<nav>
<div id="nav-pop">
<ul id="nav-list">
<li>ABOUT</li>
<li id="serviceClick" class="navItem">SOLUTIONS</li>
<li>LEARN</li>
<li>CONTACT</li>
<li>REQUEST QUOTE</li>
</ul>
</div>
</nav>
Firstly, Keep li as child of ul not anchor.
Removed the top margin on nav-pop.
Added display: flex and align-items: center on nav-list.
Reduced the after element's margin to zero.
nav {
background: #FFF;
height: 70px;
width: 100%;
max-width: 100%;
box-shadow: 0px 6px 15px -4px rgba(0, 0, 0, 0.12);
position: fixed;
top: 0;
z-index: 999;
box-sizing: border-box;
}
#nav-pop {
float: right;
display: block;
margin-right: 5%;
transition: ease 0.5s;
-webkit-transition: ease 0.5s;
}
#nav-pop.active {
opacity: 1;
background: rgba(0, 0, 0, 0.8);
background: #2f2f2f;
right: 0;
margin-top: 0;
margin-right: 0;
z-index: 999999;
transition: ease 0.6s;
-webkit-transition: ease 0.6s;
transform: translateX(0);
-webkit-transform: translateX(0);
box-shadow: -9px 0px 9px 1px rgba(0, 0, 0, .2);
}
.navItem {
display: inline-block;
margin: 0 17px;
vertical-align: top;
}
.navItem:first-child {
margin-left: 0px;
}
.navItem:last-child {
margin-right: 0px;
}
.navItem,
#serviceClick {
text-decoration: none;
font-family: 'Muli', sans-serif;
font-size: .9rem;
color: #747678;
letter-spacing: 1px;
vertical-align: top;
transition: all .3s;
-webkit-transition: all .3s;
cursor: pointer;
}
.navItem:after,
#serviceClick:after {
content: '';
display: block;
width: 0;
margin-top: 0px;
background: #b82222;
height: 2px;
transition: width .3s;
}
.navItem:hover,
#serviceClick:hover {
color: #4b4b4b;
transition: all .3s;
-webkit-transition: all .3s;
}
.navItem:hover:after,
#serviceClick:hover:after {
width: 100%;
transition: width .3s;
}
.navInverse {
padding: 10px 12px;
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.2rem;
color: #FFF;
border: 1px solid #b82222;
background: linear-gradient(to right bottom, #b82222, #a51e1e);
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
}
.navInverse:hover {
background: #b82222;
background: #FFF;
color: #b82222;
}
.navInverse:after {
content: '';
display: none;
width: 0px;
height: 0px;
transition: none;
}
#nav-list {
display: flex;
align-items: center;
}
.navItem a {
padding: 24px 12px;
}
<nav>
<div id="nav-pop">
<ul id="nav-list">
<li href="" class="navItem"><a>ABOUT</a></li>
<li id="serviceClick" class="navItem">SOLUTIONS</li>
<li href="" class="navItem"><a>LEARN</a></li>
<li href="" class="navItem"><a>CONTACT</a></li>
<li href="" class="navInverse navItem" id="quoteButton"><a>REQUEST QUOTE</a></li>
</ul>
</div>
</nav>
To get a full alignment on your navbar I removed the margin-top from the #nav-pop id it wasn't necessary. Then changed the nav-list id (because it's the container) by adding the following:
#nav-list {
display: flex;
align-items: center;
}
Giving me the desired display you're after:
The first issue I notice is that your ul #nav-list has a margin-top that may be affecting your alignment, but the most important issue is that the height of #quoteButton does not match the line-height of the rest of your links (because there is none set). This will cause vertical-align: middle to not work correctly as the elements are not the same heights.
When I set the line-height of each <li> to 44px they align perfectly. To me, the answer suggested by #billy.farroll is not sufficient as the button text does not align with the <li>s.
I am trying to create an expanding css button. I have made some progress but can't seem to get it to work unless I use absolute positioning. Is there a way to make this type of button without needing it to be absolute positioned on a page. Thanks for any help. Below is what I have so far.
I want it to work without needing to be absolutely positioned on the page.
.add-new-button {
right: 250px;
position: fixed;
width: 40px;
height: 40px;
background-color: #1BA1FC;
border-radius: 40px;
transition: width 0.3s;
overflow: hidden;
cursor: pointer;
}
.add-new-button-icon {
top: 0;
right: 0;
z-index: 4;
position: absolute;
color: #fff;
transition: transform 0.2s;
width: 40px;
height: 40px;
}
.add-new-button-icon i {
top: 12px;
height: 100%;
margin-left: 14px;
position: relative;
}
.add-new-button:hover {
width: 110px;
}
.add-new-button:hover .add-new-button-icon {
transform: rotate(90deg);
}
.add-new-button-label {
width: 80px;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
text-transform: uppercase;
font-size: 14px;
text-align: center;
font-family: "Source Sans Pro", sans-serif !important;
font-weight: 700;
position: relative;
margin-top: 5px;
padding-left: 10px;
-moz-transition: all 200ms ease-in;
-webkit-transition: all 200ms ease-in;
-o-transition: all 200ms ease-in;
transition: all 200ms ease-in;
opacity: 0;
}
.add-new-button:hover .add-new-button-label {
transition-delay: 0.1s;
visibility: visible;
opacity: 1;
color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="add-new-button">
<div class="add-new-button-label">
Add
</div>
<div class="add-new-button-icon">
<i class="fa fa-plus"></i>
</div>
</div>
It seems (to me) that your button doesn't need to have position: fixed;. All it need is some sufficient space to roll out.
#container {
border: 2px black solid;
display: flex;
justify-content: flex-end;
width: 200px;
}
.add-new-button {
position: relative;
width: 40px;
height: 40px;
background-color: #1BA1FC;
border-radius: 40px;
transition: width 0.3s;
overflow: hidden;
cursor: pointer;
}
.add-new-button-icon {
top: 0;
right: 0;
z-index: 4;
position: absolute;
color: #fff;
transition: transform 0.2s;
width: 40px;
height: 40px;
}
.add-new-button-icon i {
top: 12px;
height: 100%;
margin-left: 14px;
position: relative;
}
.add-new-button:hover {
width: 110px;
}
.add-new-button:hover .add-new-button-icon {
transform: rotate(90deg);
}
.add-new-button-label {
width: 80px;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
text-transform: uppercase;
font-size: 14px;
text-align: center;
font-family: "Source Sans Pro", sans-serif !important;
font-weight: 700;
position: relative;
margin-top: 5px;
padding-left: 10px;
-moz-transition: all 200ms ease-in;
-webkit-transition: all 200ms ease-in;
-o-transition: all 200ms ease-in;
transition: all 200ms ease-in;
opacity: 0;
}
.add-new-button:hover .add-new-button-label {
transition-delay: 0.1s;
visibility: visible;
opacity: 1;
color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div id="container">
<div class="add-new-button">
<div class="add-new-button-label">
Add
</div>
<div class="add-new-button-icon">
<i class="fa fa-plus"></i>
</div>
</div>
</div>