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>
Related
Hi everyone and thanks in advance,
i have a combination of stickyscrolls for a portfolio-site. Projects are ordered from top to bottom. The idea is to always reveal the next project from "underneath" and then having a left column with text that sticks to the top and a right column with pictures that you can scroll through. The height of the left side should always adjust to the height of the right side (that is filled with the project-pictures). The left also changes its bg-color from project to project. Everything works fine in chrome and firefox, but safari always shortens the height or to be precise: the height of the bg-color of the left side and adjusts it to the textbox. What am i missing or doing wrong? As you can see project 3 shimmers through the overlaying section in safari. I want it to be hidden under it. When using images it gets worse. The image shines through the left side. I think my html-structure is wrong.enter code here
h1 {
margin-top: 0px;
margin-bottom: 0px;
font-size: 38px;
line-height: 44px;
font-weight: 700;
}
.navbar {
position: fixed;
left: 0%;
top: 0%;
right: 0%;
bottom: auto;
z-index: 999;
width: 100%;
background-color: #fff;
}
.nav__menu {
width: 100%;
}
.nav__list {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
height: 38px;
margin-bottom: 0px;
padding-left: 0px;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
list-style-type: none;
}
.nav__item.is--absolute__left__desktop {
position: absolute;
left: 0%;
top: auto;
right: auto;
bottom: auto;
}
.nav__link {
padding: 10px 17px;
font-family: 'Basis grotesque', sans-serif;
font-size: 24px;
line-height: 0;
font-weight: 500;
}
.body {
background-color: #000;
}
.sticky__section__wrapper {
position: relative;
z-index: 130;
width: 100%;
background-color: #eb0909;
}
.project__banner {
position: relative;
z-index: 130;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
overflow: hidden;
min-height: 100vh;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.project__background {
position: absolute;
left: 0%;
top: 0%;
right: 0%;
bottom: auto;
z-index: 1;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
overflow: hidden;
width: 100%;
height: 120vh;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-o-object-fit: cover;
object-fit: cover;
}
.section__header {
position: -webkit-sticky;
position: sticky;
bottom: 0px;
z-index: 2;
height: 100vh;
background-image: none;
background-position: 50% 50%;
background-size: cover;
background-repeat: no-repeat;
}
.section__header._1 {
z-index: 18;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
background-color: #4219bd;
}
.section__header._2 {
bottom: 0px;
z-index: 10;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.sticky__left__column {
position: -webkit-sticky;
position: sticky;
top: 0vh;
z-index: 110;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 50%;
height: 100vh;
padding-right: 0px;
padding-left: 0px;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
}
.sticky__left__column.is--green {
height: auto;
background-color: #003c00;
}
.sticky__left__column.is--black {
height: 100%;
max-height: 100vh;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
background-color: #000;
}
.heading-2 {
margin-top: 0px;
margin-bottom: 1.3rem;
color: #fff;
font-size: 70px;
font-weight: 800;
}
.image__wrapper {
position: relative;
z-index: 110;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
text-align: left;
}
.image__wrapper.left-align {
position: relative;
z-index: 99;
height: 120vh;
-webkit-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
background-color: #000;
text-align: left;
}
.image__wrapper.is--50vh {
height: 50vh;
border: 1px solid #000;
background-color: #ec4141;
}
.list-item {
font-size: 0.9rem;
line-height: 1.5;
font-weight: 400;
text-align: left;
}
.large-number {
margin-bottom: 0px;
font-size: 60px;
font-weight: 200;
text-align: left;
}
.large-number.outline {
margin-bottom: 0.8rem;
}
.sticky {
position: relative;
z-index: 110;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 100%;
height: 100%;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
text-align: center;
}
.sticky.is--green {
height: 100%;
background-color: #003c00;
}
.sticky.is--black {
top: 0px;
height: 100%;
background-color: #000;
}
.relative__gallery__column {
position: -webkit-sticky;
position: sticky;
top: auto;
bottom: auto;
z-index: 110;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 50%;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.info__text__flex {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
height: 100%;
margin-top: 38px;
padding: 12px 18px 38px;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
}
.project__heading {
width: 31.6%;
font-family: 'Basis grotesque', sans-serif;
color: #fff;
font-size: 24px;
line-height: 1.17;
font-weight: 500;
text-align: left;
text-transform: uppercase;
}
.info__wrap {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
width: 65.8%;
height: 100%;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
text-align: left;
}
.project__info {
margin-bottom: 50px;
font-family: 'Basis grotesque', sans-serif;
color: #fff;
font-size: 15px;
line-height: 1.17;
}
.project__credits {
margin-bottom: 50px;
font-family: 'Basis grotesque', sans-serif;
color: #fff;
font-size: 12px;
line-height: 1.17;
}
.scroll__image {
width: 100%;
height: 100%;
max-width: none;
-o-object-fit: cover;
object-fit: cover;
}
.slider {
width: 100%;
}
.left-arrow {
display: none;
}
.right-arrow {
display: none;
}
.slide-nav {
display: none;
}
.heading {
color: #fff;
}
#media screen and (max-width: 991px) {
.nav__link {
font-size: 18px;
}
.sticky__left__column {
width: 50%;
padding-right: 35px;
padding-left: 35px;
-webkit-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
}
.heading-2 {
font-size: 50px;
}
.list-item {
font-size: 0.8rem;
}
.relative__gallery__column {
width: 50%;
padding-right: 30px;
padding-left: 30px;
}
}
#media screen and (max-width: 767px) {
.nav__list {
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
.nav__item.is--absolute__left__desktop {
position: relative;
}
.nav__link {
padding-right: 9px;
padding-left: 9px;
}
.heading-2 {
font-size: 46px;
}
}
#media screen and (max-width: 479px) {
.sticky__left__column {
position: static;
width: 100%;
height: auto;
min-height: 50vh;
}
.sticky {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.relative__gallery__column {
width: 100%;
}
}
#font-face {
font-family: 'Basis grotesque';
src: url('../fonts/basis-grotesque-medium.woff2') format('woff2');
font-weight: 500;
font-style: normal;
font-display: swap;
}
#font-face {
font-family: 'Basis grotesque';
src: url('../fonts/basis-grotesque-regular.woff2') format('woff2');
font-weight: 400;
font-style: normal;
font-display: swap;
}
<!DOCTYPE html>
<htmllang="en">
<head>
<meta charset="utf-8">
<title>PORTFOLIO</title>
<meta content="width=device-width, initial-scale=1" name="viewport">
</head>
<body class="body">
<div data-animation="default" data-collapse="none" data-duration="400" data-easing="ease" data-easing2="ease" role="banner" class="navbar w-nav">
<div class="nav__container">
<nav role="navigation" class="nav__menu w-nav-menu">
<ul role="list" class="nav__list">
<li class="nav__item is--absolute__left__desktop">
Portfolio<br>
</li>
<li class="nav__item">
INFO
</li>
</ul>
</nav>
</div>
</div>
<div class="sticky__section__wrapper">
<div class="project__banner">
<h1 class="heading">Project 1</h1>
</div>
<div id="branding-info" class="sticky is--black">
<div class="sticky__left__column is--black">
<div class="info__text__flex">
<h1 class="project__heading">Project 1</h1>
<div class="info__wrap">
<p class="project__info">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.</p>
</div>
</div>
</div>
<div class="relative__gallery__column">
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
</div>
</div>
</div>
<div class="section__header _1">
<h1 class="heading">Project 2</h1>
</div>
<div class="sticky__section__wrapper">
<div id="branding-info" class="sticky is--green">
<div class="sticky__left__column is--green">
<div class="info__text__flex">
<h1 class="project__heading">Heading</h1>
<div class="info__wrap">
<p class="project__info">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.</p>
</div>
</div>
</div>
<div class="relative__gallery__column">
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
</div>
</div>
</div>
<div class="section__header _2">
<h1 class="heading">#Project 3</h1>
</div>
<div class="sticky__section__wrapper">
<div id="branding-info" class="sticky">
<div class="sticky__left__column">
<div class="info__text__flex">
<h2 class="project__heading">Heading</h2>
<div class="info__wrap">
<p class="project__info">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.</p>
</div>
</div>
</div>
<div class="relative__gallery__column">
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
<div class="image__wrapper is--50vh"></div>
</div>
</div>
</div>
</body>
</html>
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>
I'm trying to implement a specific design but have stumbled upon quite a lot of complexities by now.
The main problem remains the background of linear gradient - it shall be stretched on the whole viewport to have the satisfactory effect (position: absolute;width: 100%;height: 100%).
But that's not the only problem, we also have a background image P above that gradient image (with higher z-index and opacity 0.3) and the gradient shall be only visible for header and footer (anything below must only have P and not gradient).
And I did that. (JSFiddle, view the code below)
Code
#index_header {
display: block;
position: relative;
}
#index_navigation {
position: relative;
top: 0px;
padding-top: 25px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
min-width: 850px;
width: 80%;
margin: 0 auto;
}
#index_logo {
display: block;
width: 150px;
height: 52px;
background-image: url("images/index/logo.png");
background-size: contain;
background-repeat: no-repeat;
}
#index_navigation_left {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_navigation_center {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
-ms-flex-preferred-size: 80%;
flex-basis: 80%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_navigation_right {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_navigation_core {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
list-style-type: none;
text-align: center;
min-width: 420px;
padding: 0;
width: 60%;
}
#index_navigation_core li {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
#index_navigation_core li a {
color: white;
font-size: 1.250em;
text-decoration: none;
cursor: pointer;
}
#navigator_authentication {
display: block;
background-color: white;
text-decoration: none;
color: #860001;
cursor: pointer;
font-size: 1.125em;
padding: 10px 30px 10px 30px;
border-radius: 20px;
}
#index_footer {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
min-width: 850px;
width: 80%;
margin: 0 auto;
}
#index_footer_left {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_footer_right {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_footer_left p {
font-size: 0.938em;
font-family: 'bpg_arialregular';
color: white;
}
#social_media_btns {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 0;
list-style-type: none;
}
#social_media_btns li {
display: inline-block;
margin-left: 10px;
margin-right: 10px;
}
#social_media_btns li a {
display: block;
width: 30px;
height: 30px;
}
#social_media_facebook {
background-size: cover;
background-image: url("images/social_media_icons/universal/facebook.png");
}
#social_media_youtube {
background-size: cover;
background-image: url("images/social_media_icons/universal/youtube.png");
}
#social_media_twitter {
background-size: cover;
background-image: url("images/social_media_icons/universal/twitter.png");
}
.present {
border-bottom: solid white 3px;
}
.nav_button {
-webkit-transition: border 0.35s ease;
-o-transition: border 0.35s ease;
transition: border 0.35s ease;
}
.nav_button:hover {
border-bottom: solid white 3px;
}
#mobile_menu {
display: none;
width: 80px;
height: 80px;
cursor: pointer;
background-image: url("images/icons/menu.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
#media only screen and (max-width: 880px) {
#index_navigation {
min-width: 300px;
}
#index_navigation_center {
display: none;
}
#mobile_menu {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_footer {
min-width: 300px;
}
}
#media only screen and (max-width: 500px) {
#navigator_authentication {
font-size: 0.9em;
padding: 5px 10px 5px 10px;
}
#mobile_menu {
width: 60px;
height: 60px;
}
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
background-color: #F5F5F5;
}
#index_overlay {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
width: 100%;
height: 100%;
z-index: 0;
}
#index_header {
z-index: 3;
}
#about_pattern {
position: absolute;
z-index: 1;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-image: url("https://i.imgur.com/F8SFW2p.png");
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height: 100%;
opacity: 0.3;
}
#about_pattern_2 {
position: absolute;
z-index: -1;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: linear-gradient(180deg, rgba(100, 0, 1, 0.75) 0%, rgba(189, 0, 1, 0.75) 24.86%, rgba(210, 0, 1, 0.75) 82.87%, rgba(100, 0, 1, 0.75) 100%);
border: 1px solid #000000;
box-sizing: border-box;
}
#index_navigation {
padding-bottom: 25px;
}
#nav_background {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
}
#about_center {
position: relative;
display: flex;
z-index: -1;
overflow-y: scroll;
flex-grow: 1;
}
#about_background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #F5F5F5;
z-index: -1;
}
#foot_background {
display: inline-block;
position: absolute;
width: 100%;
height: 100%;
}
#intro_text {
position: relative;
padding-left: 10%;
padding-right: 10%;
padding-top: 60px;
padding-bottom: 60px;
font-size: 1.125em;
text-decoration: none;
line-height: normal;
flex-direction: column;
justify-content: space-between;
min-height: 100%;
overflow-y: auto;
text-align: left;
color: #4F4F4F;
}
footer {
position: relative;
padding-top: 25px;
padding-bottom: 25px;
flex-shrink: 0;
z-index: 3;
}
<!DOCTYPE html>
<html lang="ge">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="about.css" type="text/css" charset="utf-8">
<link rel="stylesheet" href="universal.css" type="text/css" charset="utf-8">
</head>
<body>
<div id="index_overlay">
<div id="about_pattern"></div>
<div id="about_pattern_2"></div>
<header id="index_header">
<div id="nav_background"></div>
<div id="index_navigation">
<div id="index_navigation_left">
<a id="index_logo" href="/"></a>
</div>
<div id="index_navigation_center">
<ul id="index_navigation_core">
<li>
btn1
</li>
<li>
btn2
</li>
<li>
btn3
</li>
</ul>
</div>
<div id="mobile_menu"></div>
<div id="index_navigation_right">
btn4
</div>
</div>
</header>
<div id="about_center">
<div id="about_background"></div>
<div id="intro_text">
<div style="text-align: center;">text here</div>
<br><br> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
<footer>
<div id="foot_background"></div>
<div id="index_footer">
<div id="index_footer_left">
<p>© 2018 mysite</p>
</div>
<div id="index_footer_right">
<ul id="social_media_btns">
<li>
<a target="_blank" id="social_media_facebook"></a>
</li>
<li>
<a target="_blank" id="social_media_youtube"></a>
</li>
<li>
<a id="social_media_twitter"></a>
</li>
</ul>
</div>
</div>
</footer>
</div>
<script src="scripts/jquery/jquery.js"></script>
<script src="scripts/custom/main.js"></script>
</body>
</html>
Problem:
Even though I visually achieved it, there's a significant concern for practical usage.
If you look at the code, #about_pattern is a background image P and #about_pattern_2 is a gradient image.
#about_center element that is stuck between header and footer, must have lower z-index compared to #about_pattern (so it can pass through) and equal or higher z-index compared to #about_pattern2 (so we don't have gradient effect there).
But #about_pattern being on the top, makes every element in #about_center not accessible to user. Which seems to be a big problem if someone wants to for example scroll through text...
Is it possible to achieve this effect without blocking the central element? Thank you!
A solution is to remove z-index from #about_center to avoid stacking context issue1 then you will able to place #about_background and #intro_text like you want as they will be in the same stacking context of the gradient background. You can then place one below and the other above.
So you remove this:
#about_center {
position: relative;
display: flex;
/*z-index: -1; */
overflow-y: scroll;
flex-grow: 1;
}
And add this:
#intro_text {
....
z-index:3;
}
Full code:
https://jsfiddle.net/tfx9pLrq/3/
#index_header {
display: block;
position: relative;
}
#index_navigation {
position: relative;
top: 0px;
padding-top: 25px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
min-width: 850px;
width: 80%;
margin: 0 auto;
}
#index_logo {
display: block;
width: 150px;
height: 52px;
background-image: url("images/index/logo.png");
background-size: contain;
background-repeat: no-repeat;
}
#index_navigation_left {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_navigation_center {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
-ms-flex-preferred-size: 80%;
flex-basis: 80%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_navigation_right {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_navigation_core {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
list-style-type: none;
text-align: center;
min-width: 420px;
padding: 0;
width: 60%;
}
#index_navigation_core li {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
#index_navigation_core li a {
color: white;
font-size: 1.250em;
text-decoration: none;
cursor: pointer;
}
#navigator_authentication {
display: block;
background-color: white;
text-decoration: none;
color: #860001;
cursor: pointer;
font-size: 1.125em;
padding: 10px 30px 10px 30px;
border-radius: 20px;
}
#index_footer {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
min-width: 850px;
width: 80%;
margin: 0 auto;
}
#index_footer_left {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_footer_right {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_footer_left p {
font-size: 0.938em;
font-family: 'bpg_arialregular';
color: white;
}
#social_media_btns {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 0;
list-style-type: none;
}
#social_media_btns li {
display: inline-block;
margin-left: 10px;
margin-right: 10px;
}
#social_media_btns li a {
display: block;
width: 30px;
height: 30px;
}
#social_media_facebook {
background-size: cover;
background-image: url("images/social_media_icons/universal/facebook.png");
}
#social_media_youtube {
background-size: cover;
background-image: url("images/social_media_icons/universal/youtube.png");
}
#social_media_twitter {
background-size: cover;
background-image: url("images/social_media_icons/universal/twitter.png");
}
.present {
border-bottom: solid white 3px;
}
.nav_button {
-webkit-transition: border 0.35s ease;
-o-transition: border 0.35s ease;
transition: border 0.35s ease;
}
.nav_button:hover {
border-bottom: solid white 3px;
}
#mobile_menu {
display: none;
width: 80px;
height: 80px;
cursor: pointer;
background-image: url("images/icons/menu.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
#media only screen and (max-width: 880px) {
#index_navigation {
min-width: 300px;
}
#index_navigation_center {
display: none;
}
#mobile_menu {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#index_footer {
min-width: 300px;
}
}
#media only screen and (max-width: 500px) {
#navigator_authentication {
font-size: 0.9em;
padding: 5px 10px 5px 10px;
}
#mobile_menu {
width: 60px;
height: 60px;
}
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
}
body {
background-color: #F5F5F5;
}
#index_overlay {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
width: 100%;
height: 100%;
z-index: 0;
}
#index_header {
z-index: 3;
}
#about_pattern {
position: absolute;
z-index: 1;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-image: url("https://i.imgur.com/F8SFW2p.png");
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height: 100%;
opacity: 0.3;
}
#about_pattern_2 {
position: absolute;
z-index: -1;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: linear-gradient(180deg, rgba(100, 0, 1, 0.75) 0%, rgba(189, 0, 1, 0.75) 24.86%, rgba(210, 0, 1, 0.75) 82.87%, rgba(100, 0, 1, 0.75) 100%);
border: 1px solid #000000;
box-sizing: border-box;
}
#index_navigation {
padding-bottom: 25px;
}
#nav_background {
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
}
#about_center {
position: relative;
display: flex;
overflow-y: scroll;
flex-grow: 1;
}
#about_background {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #F5F5F5;
z-index: -1;
}
#foot_background {
display: inline-block;
position: absolute;
width: 100%;
height: 100%;
}
#intro_text {
position: relative;
padding-left: 10%;
padding-right: 10%;
padding-top: 60px;
padding-bottom: 60px;
font-size: 1.125em;
text-decoration: none;
line-height: normal;
flex-direction: column;
justify-content: space-between;
min-height: 100%;
overflow-y: auto;
text-align: left;
color: #4F4F4F;
z-index: 3;
}
footer {
position: relative;
padding-top: 25px;
padding-bottom: 25px;
flex-shrink: 0;
z-index: 3;
}
<div id="index_overlay">
<div id="about_pattern"></div>
<div id="about_pattern_2"></div>
<header id="index_header">
<div id="nav_background"></div>
<div id="index_navigation">
<div id="index_navigation_left">
<a id="index_logo" href="/"></a>
</div>
<div id="index_navigation_center">
<ul id="index_navigation_core">
<li>
btn1
</li>
<li>
btn2
</li>
<li>
btn3
</li>
</ul>
</div>
<div id="mobile_menu"></div>
<div id="index_navigation_right">
btn4
</div>
</div>
</header>
<div id="about_center">
<div id="about_background"></div>
<div id="intro_text">
<div style="text-align: center;">text here</div>
<br><br> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen
book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
</div>
<footer>
<div id="foot_background"></div>
<div id="index_footer">
<div id="index_footer_left">
<p>© 2018 mysite</p>
</div>
<div id="index_footer_right">
<ul id="social_media_btns">
<li>
<a target="_blank" id="social_media_facebook"></a>
</li>
<li>
<a target="_blank" id="social_media_youtube"></a>
</li>
<li>
<a id="social_media_twitter"></a>
</li>
</ul>
</div>
</div>
</footer>
</div>
1For a more accurate explanation we can refer to the specification:
For those with 'z-index: auto', treat the element as if it created a
new stacking context, but any positioned descendants and descendants
which actually create a new stacking context should be considered part
of the parent stacking context, not this new one.
So by removing z-index it will fall back to auto and we removed the restriction of making our elements in the stacking context of their parent and controled by the z-index of their parent. They now belong to the upper stacking context which is the same as the gradient.
In other words, adding z-index to the parent element will make z-index of child elements to only be consider inside their parent after that everything will be placed considering the z-index of the parent. Either everything will be above the gradient or everything below it.
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>
I have a div with a background image and a linear-gradient overlay. I would like to transition the linear-gradient to completely transparent when the div is hovered over.
.board-grid {
display: flex;
justify-content: center;
flex-direction: row;
}
.board-focus {
margin: 10px;
background: #FFF;
text-decoration: None;
border-radius: 10px;
height:30vh;
width:25vw;
display: flex;
align-items: center;
justify-content: center;
}
.board-name {
text-transform: uppercase;
//max-width: 50%;
color: #FFF;
}
<div class="board-grid">
<a href=''>
<div class="board-focus" style="background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(https://placeimg.com/480/300/any); background-size: cover; background-position: center center; background-repeat: no-repeat;">
<div class="board-name">
<p>John Doe</p>
</div>
</div>
</a>
</div>
Fiddle
.board-grid {
display: flex;
justify-content: center;
flex-direction: row;
}
.board-focus {
margin: 10px;
background: #FFF;
border-radius: 10px;
height:30vh;
width:25vw;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.board-name {
text-transform: uppercase;
max-width: 50%;
color: #FFF;
z-index: 999;
}
.board-focus::after{
content: ' ' ;
background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5));
position: absolute;
display: block;
width:100%;
top:0;
left:0;
height:100%;
border-radius: 10px;
z-index: 10;
}
.board-focus:hover::after{
content: ' ';
display: none;
}
<div class="board-grid">
<a href='' style="text-decoration: none">
<div class="board-focus" style="background-image: url(https://placeimg.com/480/300/any); background-size: cover; background-position: center center; background-repeat: no-repeat;">
<div class="board-name">
<p>John Doe</p>
</div>
</div>
</a>
</div>
You Can use code like below
.board-grid {
display: flex;
justify-content: center;
flex-direction: row;
}
.board-focus {
margin: 10px;
background: #FFF;
text-decoration: None;
border-radius: 10px;
height:30vh;
width:25vw;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(https://placeimg.com/480/300/any);
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.board-name {
text-transform: uppercase;
// max-width: 50%;
color: #FFF;
}
.board-focus:hover
{
background-image:url(https://placeimg.com/480/300/any);;
}
<div class="board-grid">
<a href=''><div class="board-focus" style="">
<div class="board-name">
<p>John Doe</p>
</div>
</div></a>
</div>
</a>
</div>