Logo in navigation bar positioning - html

I know there are a lot of questions about this, I've tried some of them and I didn't have that much luck.
I have this structure:
HTML:
<header>
<div class="logo">
<a><img style="height: 50px;" src="https://user94.files.wordpress.com/2009/12/ubuntu-logo.png"></a>
</div>
<div class="header-content">
<nav>
About me
Education
Personal life
My work
Contact me
</nav>
</div>
</header>
CSS:
header {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
align-items: center;
align-items: center;
text-align: center;
min-height: 100vh;
width: 100%;
background: url(http://via.placeholder.com/1920x1080) no-repeat 10% 10% / cover;
}
.header-content {
margin-top: 2em;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;;
justify-content: center;
align-items: center;
text-align: center;
}
.logo{
padding-right: 0;
}
nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
font-weight: 400;
color: rgb(49, 41, 61);
font-size: .8em;
margin-top: 2em;
margin-left: 30em;
}
I'm trying to move the logo to the left without affecting my navigation items to the right, I was so much in trouble getting the nav items to the right and over the image that I don't get how to make both of them positioned correctly.
How can I make it work?
https://codepen.io/anon/pen/zLMzpO

This CSS for header should do what you want:
header {
display: flex;
align-items: baseline;
justify-content: space-between;
min-height: 100vh;
background: url(http://via.placeholder.com/1920x1080) no-repeat 10% 10% / cover;
}
https://codepen.io/anon/pen/YjRQRV
(no column direction, justify-content: space-between; and align-items: baseline; are the essential changes to your version)

Here is my solution:
.logo{
padding-right: 0;
opacity: 1;
}
.logo img{
opacity: 0;
}
.logo::after{
content: "";
width: 50px;
height: 54px;
opacity: 0.99;
position: absolute;
top: 10px;
left: 10px;
background: url("https://user94.files.wordpress.com/2009/12/ubuntu-logo.png") no-repeat;
background-size: 100% 100%;
}

in navigation bar you should use flex-direction: row.
here is a useful link flexbox basic navigation - menu items and logo
body{
margin:0;
}
header {
display: flex;
align-items: baseline;
justify-content: space-between;
min-height: 100vh;
background: url(http://via.placeholder.com/1920x1080) no-repeat 10% 10% / cover;
}
.header-content {
margin-top: 2em;
}
header a,
header a:visited {
color: rgb(252, 252, 252);
text-decoration: none;
padding-bottom: 0.1em;
}
header a:hover {
color: #FA26BF;
}
.logo{
padding-right: 0;
}
.logo img{
vertical-align: bottom;
}
nav {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row;
flex-direction: row;
font-weight: 400;
color: rgb(49, 41, 61);
font-size: .8em;
margin-top: 2em;
margin-left: 30em;
}
nav a {
margin: 1em;
}
nav a,
nav a:visited {
padding-bottom: 0.1em;
letter-spacing: 0.1em;
text-decoration: none;
color: rgb(252, 252, 252);
}
nav a:hover,
nav a:active {
color: #FA26BF;
}
<header>
<div class="logo">
<a><img style="height: 50px;" src="https://user94.files.wordpress.com/2009/12/ubuntu-logo.png"></a>
</div>
<div class="header-content">
<nav>
About me
Education
Personal life
My work
Contact me
</nav>
</div>
</header>

Related

Drop down box not visible

When hoovering the menu element a drop down box shall appear. It does but it is cut. Not sure what is wrong here if the Ul nav list cuts it. The drop down menu has been tested ok but not with this menu. I also tried to change the z-index, but without any result. Can you see anything that can inhibit the drop down menu to show?
var navList = document.getElementById("nav-lists");
function Show() {
navList.classList.add("_Menus-show");
}
function Hide() {
navList.classList.remove("_Menus-show");
}
*,
*::before,
*::after {
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
body {
font-family: sans-serif;
margin: 0;
padding: 0;
}
.container {
height: 80px;
background-color: #333333;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
overflow: hidden;
}
.container .logo {
max-width: 250px;
padding: 0 10px;
overflow: hidden;
}
.container .logo a {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
height: 60px;
}
.container .logo a img {
max-width: 100%;
max-height: 60px;
}
.container .navbar {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
padding: 0 10px;
}
.container .navbar ul {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
list-style: none;
margin: 0;
padding: 0;
}
.container .navbar ul li a {
text-decoration: none;
color: #999999;
font-size: 20px;
text-transform: uppercase;
display: block;
height: 60px;
line-height: 60px;
cursor: pointer;
padding: 0 10px;
}
.container .navbar ul li a:hover {
color: #ffffff;
background-color: rgba(23, 23, 23, 0.9);
}
.container .navbar ul .close {
display: none;
text-align: right;
padding: 10px;
}
.container .navbar ul .close span {
font-size: 40px;
display: inline-block;
border: 1px solid #cccccc;
padding: 0 10px;
cursor: pointer;
}
.container .navbar .icon-bar {
padding: 18px 8px;
width: 50px;
height: 60px;
display: none;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
cursor: pointer;
}
.container .navbar .icon-bar i {
background-color: #ffffff;
height: 2px;
}
#media only screen and (max-width: 650px) {
.container {
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.container .logo {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
}
.container .navbar {
-webkit-box-flex: 0;
-ms-flex: 0;
flex: 0;
}
.container .navbar ul {
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
position: fixed;
left: 100%;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
background: #ffffff;
width: 100%;
height: 100%;
overflow: auto;
-webkit-transition: left .3s;
-o-transition: left .3s;
transition: left .3s;
}
.container .navbar ul li a {
padding: 10px;
font-size: 20px;
height: auto;
line-height: normal;
color: #555555;
}
.container .navbar ul .close {
display: block;
}
.container .navbar .icon-bar {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.container .navbar ._Menus-show {
left: 0;
}
}
.body {
max-width: 700px;
margin: 0 auto;
padding: 10px;
}
/* start of drop down */
/* dropdown css starts here */
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #0009f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 10;
}
.dropdown:hover .dropdown-content {
display: block;
}
.desc {
padding: 15px;
width: 400px;
height: 160px;
font-family: Arial;
}
.desc_Info {
padding: 15px;
width: 400px;
height: 220px;
font-family: Arial;
}
span {
cursor: pointer;
}
/* hand over menu item */
/* END drop down menu */
<html>
<head>
<title>Nav bar</title>
</head>
<body>
<div class="container">
<div class="logo">
<img src="./bilder/logo2.jpg" alt="Start">
</div>
<div class="navbar">
<div class="icon-bar" onclick="Show()">
<i></i>
<i></i>
<i></i>
</div>
<ul id="nav-lists">
<li class="close"><span onclick="Hide()">×</span></li>
<li class="elements">
<div class="dropdown">
Cars
<div class="dropdown-content">
<div class="desc">assadsadsad<br /><br /> asdasdsadasdsadsad
<br /><br /> adsasdsasaasdasdasdsdasad
</div>
</div>
</div>
</li>
<li>Bikes</li>
</ul>
</div>
</div>
<div class="body">
<p>Hello yes !</p>
</div>
</body>
</html>
Remove the overflow: hidden; from the .container. This cuts off the dropdown.
var navList = document.getElementById("nav-lists");
function Show() {
navList.classList.add("_Menus-show");
}
function Hide() {
navList.classList.remove("_Menus-show");
}
*,
*::before,
*::after {
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
body {
font-family: sans-serif;
margin: 0;
padding: 0;
}
.container {
height: 80px;
background-color: #333333;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.container .logo {
max-width: 250px;
padding: 0 10px;
overflow: hidden;
}
.container .logo a {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
height: 60px;
}
.container .logo a img {
max-width: 100%;
max-height: 60px;
}
.container .navbar {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
padding: 0 10px;
}
.container .navbar ul {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
list-style: none;
margin: 0;
padding: 0;
}
.container .navbar ul li a {
text-decoration: none;
color: #999999;
font-size: 20px;
text-transform: uppercase;
display: block;
height: 60px;
line-height: 60px;
cursor: pointer;
padding: 0 10px;
}
.container .navbar ul li a:hover {
color: #ffffff;
background-color: rgba(23, 23, 23, 0.9);
}
.container .navbar ul .close {
display: none;
text-align: right;
padding: 10px;
}
.container .navbar ul .close span {
font-size: 40px;
display: inline-block;
border: 1px solid #cccccc;
padding: 0 10px;
cursor: pointer;
}
.container .navbar .icon-bar {
padding: 18px 8px;
width: 50px;
height: 60px;
display: none;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
cursor: pointer;
}
.container .navbar .icon-bar i {
background-color: #ffffff;
height: 2px;
}
#media only screen and (max-width: 650px) {
.container {
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
.container .logo {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
}
.container .navbar {
-webkit-box-flex: 0;
-ms-flex: 0;
flex: 0;
}
.container .navbar ul {
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
position: fixed;
left: 100%;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
background: #ffffff;
width: 100%;
height: 100%;
overflow: auto;
-webkit-transition: left .3s;
-o-transition: left .3s;
transition: left .3s;
}
.container .navbar ul li a {
padding: 10px;
font-size: 20px;
height: auto;
line-height: normal;
color: #555555;
}
.container .navbar ul .close {
display: block;
}
.container .navbar .icon-bar {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.container .navbar ._Menus-show {
left: 0;
}
}
.body {
max-width: 700px;
margin: 0 auto;
padding: 10px;
}
/* start of drop down */
/* dropdown css starts here */
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #0009f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 10;
}
.dropdown:hover .dropdown-content {
display: block;
}
.desc {
padding: 15px;
width: 400px;
height: 160px;
font-family: Arial;
}
.desc_Info {
padding: 15px;
width: 400px;
height: 220px;
font-family: Arial;
}
span {
cursor: pointer;
}
/* hand over menu item */
/* END drop down menu */
<html>
<head>
<title>Nav bar</title>
</head>
<body>
<div class="container">
<div class="logo">
<img src="./bilder/logo2.jpg" alt="Start">
</div>
<div class="navbar">
<div class="icon-bar" onclick="Show()">
<i></i>
<i></i>
<i></i>
</div>
<ul id="nav-lists">
<li class="close"><span onclick="Hide()">×</span></li>
<li class="elements">
<div class="dropdown">
Cars
<div class="dropdown-content">
<div class="desc">assadsadsad<br /><br /> asdasdsadasdsadsad
<br /><br /> adsasdsasaasdasdasdsdasad
</div>
</div>
</div>
</li>
<li>Bikes</li>
</ul>
</div>
</div>
<div class="body">
<p>Hello yes !</p>
</div>
</body>
</html>

Logo as link to Home-page

When I set the logo as a link, my menu moves to the right. When I inspect the menu, I see that I get an extra menu link to the left of the menu that is not visible otherwise and which leads to index.html Does anyone know what is the reason for this?
#logo {
height: 64px;
position: absolute;
left: 20px;
}
#menu {
display: flex;
flex-direction: row;
justify-content: center;
}
nav {
width: 100%;
background-color: #000000;
height: 64px;
display: flex;
flex-direction: row;
justify-content: center;
}
nav a {
text-align: center;
font-size: 25px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
width: 100px;
color: white;
text-decoration: none;
transition: .9s;
}
nav a:hover {
background-color: orange;
transition: .9s;
}
<nav>
<div>
<img id="logo" src="https://via.placeholder.com/400x400.jpg" alt="">
</div>
<div id="menu">
<a href=index.html>Home</a>
<a href=index.html>About</a>
<a href=index.html>Contact</a>
</div>
</nav>
Change the css nav ato nav #menu a- Hope it fix the style.
#logo {
height: 64px;
position: absolute;
left: 20px;
}
#menu {
display: flex;
flex-direction: row;
justify-content: center;
}
nav {
width: 100%;
background-color: #000000;
height: 64px;
display: flex;
flex-direction: row;
justify-content: center;
}
nav #menu a {
text-align: center;
font-size: 25px;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
width: 100px;
color: white;
text-decoration: none;
transition: .9s;
}
nav a:hover {
background-color: orange;
transition: .9s;
}
<nav>
<div>
<img id="logo" src="https://via.placeholder.com/400x400.jpg" alt="">
</div>
<div id="menu">
<a href=index.html>Home</a>
<a href=index.html>About</a>
<a href=index.html>Contact</a>
</div>
</nav>

CSS text align not working as expected when combined with flex

I have a vertical navigation bar like so where I want the '.line' element to push the 'a' text element to the left as the '.line' element grows. However, growing just one of the lines pushes all the texts by the same amount to the left, essentially moving the entire navigation bar. I think it might have something to do with text-align, which I am trying to keep for formatting. I have attached the relevant code recreating the situation described, please take a look.
nav {
-webkit-transform: translateY(22vh);
-ms-transform: translateY(22vh);
transform: translateY(22vh);
position: fixed;
right: 0;
overflow-x: hidden;
z-index: 1000 !important;
opacity: 1;
margin: 10px 0 10px 10px;
}
nav div {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
margin: 20px 0;
}
nav div a {
display: inline-block;
margin-right: 10px;
color: black;
font-size: 18px;
text-decoration: none;
}
nav div .line {
display: block;
margin: 0px;
width: 0px;
height: 1.5px;
float: right;
background-color: black;
opacity: 0;
}
nav div #tab-2 .line {
width: 80px;
opacity: 1;
}
<nav>
<div id="tab-1">
About
<div class="line"></div>
</div>
<div id="tab-2">
About
<div class="line"></div>
</div>
<div id="tab-3">
About
<div class="line"></div>
</div>
</nav>
So far, I've tried doing things like manually increasing the size of the '#tab-#' div container while increasing the width of the line, while keeping a max-width on the rest of the rows, but that did not work.
Here is a visual representation of what I want the end result to be
One of the options is:
nav {
display: flex;
flex-direction: column;
align-items: flex-end;
}
Update
You can try with the following:
nav {
-webkit-transform: translateY(22vh);
-ms-transform: translateY(22vh);
transform: translateY(22vh);
position: fixed;
right: 0;
overflow-x: hidden;
z-index: 1000 !important;
opacity: 1;
margin: 10px 0 10px 10px;
}
nav div {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
margin: 20px 0;
}
nav div a {
display: inline-block;
margin-right: 10px;
color: black;
font-size: 18px;
text-decoration: none;
}
nav div .line {
display: block;
margin: 0px;
width: 0px;
height: 1.5px;
float: right;
background-color: black;
opacity: 0;
}
nav div#tab-2 .line {
width: 80px;
opacity: 1;
}
nav div {
position: relative;
width: 150px;
}
nav div a {
position: absolute;
right: 40px;
}
nav div#tab-2 a {
position: relative;
right: 0;
}
<nav>
<div id="tab-1">
About
<div class="line"></div>
</div>
<div id="tab-2">
About
<div class="line"></div>
</div>
<div id="tab-3">
About
<div class="line"></div>
</div>
</nav>
Or, with hover effect (to be improved, but gives the idea):
nav {
-webkit-transform: translateY(22vh);
-ms-transform: translateY(22vh);
transform: translateY(22vh);
position: fixed;
right: 0;
overflow-x: hidden;
z-index: 1000 !important;
opacity: 1;
margin: 10px 0 10px 10px;
}
nav div {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
margin: 20px 0;
}
nav div a {
display: inline-block;
margin-right: 10px;
color: black;
font-size: 18px;
text-decoration: none;
}
nav div .line {
display: block;
margin: 0px;
width: 0px;
height: 1.5px;
float: right;
background-color: black;
opacity: 0;
}
nav div {
position: relative;
width: 150px;
}
nav div a {
position: absolute;
right: 40px;
}
nav div:hover a {
position: relative;
right: 0;
}
nav div .line {
width: 0;
opacity: 0;
}
nav div:hover .line {
width: 80px;
opacity: 1;
}
<nav>
<div id="tab-1">
About
<div class="line"></div>
</div>
<div id="tab-2">
About
<div class="line"></div>
</div>
<div id="tab-3">
About
<div class="line"></div>
</div>
</nav>

Flexbox with unexpected whitespace at top

I have an issue with a flexbox not filling up all the way to my navbar, I cannot for the life of me figure it out and a negative margin does absolutely nothing
Here's a screenshot
.hero {
background-image: url("https://unsplash.it/1500?random");
background-size: cover;
background-position: center;
width: 100%;
height: 100%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin-top: -10px;
}
.hero>.center-content {
width: 400px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin: auto;
}
.hero>.center-content h1,
.center-content h3 {
color: white;
line-height: 1;
}
.hero>.center-content h1 {
text-transform: uppercase;
font-size: 3em;
margin-bottom: 0;
text-align: center;
}
.hero>.center-content h3 {
margin-bottom: 40px;
font-size: 1.5em;
font-weight: normal;
}
.center-content>.button {
text-transform: uppercase;
color: white;
padding: 20px;
border: 1px solid white;
text-decoration: none;
}
.center-content>.button:hover {
background-color: rgba(255, 255, 255, 0.3);
border-color: rgba(255, 255, 255, 0.7);
color: #006594;
}
<div class="container" id="heroImage">
<div class="hero">
<div class="center-content">
<h1>Lazris</h1>
<h3>Revive Your Web Presence</h3>
Some Action Here
</div>
</div>
</div>
Remove the margin top on your active menu
.nav > .active {
/** margin-top: 10px; Remove **/
}

CSS positioning not centering in IE but is in Chrome

Hi my friend is having trouble centering the text in the middle of the margins.
When I look at this site in IE 11 it just doesn't seem to center, could some one help me as to why?
<header id="site-header" class="site-header valign-center">
<div class="intro">
<h2>x</h2>
<p> y </p>
<h1>z</h1>
<a class="btn btn-white" data-scroll href="#foo">button</a>
</div>
</header>
The CSS:
.site-header {
width: 100%;
height: 100%;
min-height: 100vh;
position: relative;
text-align: center;
background: url(../images/backgrounds/header.jpg) no-repeat center center/cover;
}
.valign-center {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.site-header .intro {
color: #fff;
position: relative;
text-align: center;
text-transform: uppercase;
width: 100%;
z-index: 1;
padding: 0 15px;
}
I've tried margin: 0 auto; but it doesn't change.
Many Thanks,
Add html, body { height: 100%; }
html,body {
height: 100%;
}
.site-header {
width: 100%;
height: 100%;
min-height: 100vh;
position: relative;
text-align: center;
background: url(../images/backgrounds/header.jpg) no-repeat center center/cover;
}
.valign-center {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.site-header .intro {
position: relative;
text-align: center;
text-transform: uppercase;
width: 100%;
z-index: 1;
padding: 0 15px;
}
<header id="site-header" class="site-header valign-center">
<div class="intro">
<h2>x</h2>
<p> y </p>
<h1>z</h1>
<a class="btn btn-white" data-scroll href="#foo">button</a>
</div>
</header>
Or you can just use height: 100vh on .site-header
.site-header {
width: 100%;
height: 100vh;
position: relative;
text-align: center;
background: url(../images/backgrounds/header.jpg) no-repeat center center/cover;
}
.valign-center {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.site-header .intro {
position: relative;
text-align: center;
text-transform: uppercase;
width: 100%;
z-index: 1;
padding: 0 15px;
}
<header id="site-header" class="site-header valign-center">
<div class="intro">
<h2>x</h2>
<p> y </p>
<h1>z</h1>
<a class="btn btn-white" data-scroll href="#foo">button</a>
</div>
</header>