Flexbox vertical overflow issue - css

I am trying to create a portfolio page for FreeCodeCamp using flexbox for the layout, but I'm having trouble with vertical overflow. The HTML:
<div class="flex-container flex-column top">
<header class="flex-container">
<h1 class="logo"><i class="fa fa-hashtag"></i>DubDev</h1>
<nav>
<ul>
<li>ABOUT</li>
<li>PORTFOLIO</li>
<li>CONTACT</li>
</ul>
</nav>
</header>
<main class="flex-container">
<a name="about"></a>
<section class="about">
<h2>About Me</h2>
</section>
<a name="project"></a>
<section class="projects flex-container">
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
<article class="card flex-container flex-column">
<img src="http://fpoimg.com/300x250">
<div class="card-title">
<h2>Project 1</h2>
</div>
</article>
</section>
<a name="contact"></a>
<section class="contact">
<h2>Contact Me </h2>
</section>
</main>
<footer class="flex-container">
<p>© 2016 Dubrick Development<p>
</footer>
</div>
The CSS:
#import url(https://fonts.googleapis.com/css?family=Passion+One:400,700);
#import url(https://fonts.googleapis.com/css?family=Droid+Serif:700);
*, *:before, *:after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
html, body {
height: 100%;
}
footer, header {
font-family: "Passion One", sans-serif;
font-weight: 400;
background: #1abc9c;
color: white;
width: 100%;
/* flex: 0 0 75px; */
}
footer, header > * {
padding: 0 5px 0 5px;
}
footer {
box-shadow:4px -4px 0 rgba(0,0,0,0.1);
justify-content: center;
align-items: center;
font-size: 18px;
}
header {
box-shadow:4px 4px 0 rgba(0,0,0,0.1);
}
main {
flex-wrap: wrap;
overflow-y: auto;
background-color: #909AA1;
justify-content: center;
position: relative;
flex: 0 1 auto;
}
nav {
flex: 1;
align-self: center;
text-align: right;
padding-right: 20px;
}
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
}
nav ul li {
display: inline;
font-size: 36px;
padding: 10px;
transition: background-color 0.5s ease;
}
nav ul li:hover {
background-color: rgba(0,0,0,0.2);
}
nav ul li a {
color: white;
text-decoration: none;
}
.about {
flex-basis: 1000px;
}
.card {
box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.24), 0 1.5px 6px rgba(0, 0, 0, 0.12);
flex-basis: 300px;
height: 300px;
margin: 10px;
align-items: center;
}
.card > img {
flex-basis: 250px;
}
.card .card-title {
background-color: white;
flex: 1;
align-self: stretch;
text-align: center;
font-family: "Droid Serif";
}
.flex-container {
display: flex;
}
.flex-column {
flex-direction: column;
}
.logo {
padding: 5px;
border-radius: 5px;
border: 1px solid white;
box-shadow: 1px 1px 5px rgba(0,0,0,0.3);
text-shadow:4px 4px 0 rgba(0,0,0,0.1);
}
.projects {
flex: 0 1 1000px;
flex-wrap: wrap;
justify-content: center;
padding-top: 20px;
padding-bottom: 20px;
background-color: #D8DBDE;
max-height: 100%;
}
.contact {
flex-basis: 1000px;
}
.top {
height: 100%;
}
If I don't set height: 100%; on the top div, there is no overflow, but it doesn't seem to "flex"; that is, main does not fill the space between the header and footer with the header and footer remaining sticky. If I do set height: 100%; on the top div, as shown in the code, main fills the available space, but the flex-item children of section class="projects" now overflow. I'm very new to flexbox, so I'm probably doing something stupid here, but I can't figure out what it is.
Link to codepen

This should be the most apt-solution for you.
if you want your header's height to be relative then you will have to use jquery else you can just set a margin-top: 90px; to #content
new css required
.content{
position: relative;
}
#top-1 {
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
height: 60px;
margin: 0;
}
small js required to adjust content's margin-top (jquery required)
$(document).ready(function() {
$('#content').css('margin-top', $('#top-1').height() + 'px');
});
http://codepen.io/Rohithzr/pen/PNKmwb

Related

Can't seem to get containers aligned properly even though I am using flexbox

import "./portfolio.scss"
export default function portfolio() {
return (
<div className="portfolio" id="portfolio">
<h1>Portfolio</h1>
<ul>
<li className="active">Featured</li>
<li>Web app</li>
<li>Mobile app</li>
<li>Design</li>
<li>Branding</li>
</ul>
<div className="container">
<div className="item">
<img
src="assets/default-product-image.png"
alt="" />
<h3>Coming soon</h3>
</div>
<div className="container">
<div className="item">
<img
src="assets/default-product-image.png"
alt=""/>
<h3>Coming soon</h3>
</div>
<div className="container">
<div className="item">
<img
src="assets/default-product-image.png"
alt=""/>
<h3>Coming soon</h3>
</div>
</div>
</div>
</div>
</div>
)
}
This is my .jsx I am making div's with containers in them and the containers seem to not be aligned properly, see the picture below.
I am trying to get them all aligned with even margin but the third one seems to be off, when i change the device on which i view it tho they align perfectly below each other.
and this is my scss
#import "../../global.scss";
.portfolio{
background-color: lightblue;
display: flex;
flex-direction: column;
align-items: center;
h1{
font-style: 500px;
}
ul{
margin: 10px;
padding: 0;
list-style: none;
display: flex;
li{
font-size: 14px;
margin-right: 9px;
padding: 7px;
border-radius: 10px;
cursor: pointer;
&.active{
background-color: $mainColor;
color: white;
}
}
}
.container{
width: 70%;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
.item{
width: 220px;
height: 150px;
border-radius: 20px;
border: 1px solid rgb(240, 234, 234);
margin: 10px 20px;
display: flex;
align-items: center;
justify-content: center;
color: white;
position: relative;
h3{
position: absolute;
font-style: 20px;
}
img{
width: 100%;
height: 100%;
object-fit: cover;
z-index: 1;
}
&:hover{
background-color: $mainColor;
img{
opacity: 0;
z-index: 0;
}
}
}
}
}
This is what it looks like right now I want the items to be evenly spread apart.
The way you have the <div class='container'>s nested is probably what is causing misalignment. I don't see any images in your question, but I'm willing to bet your code is producing containers that get smaller and smaller the further down the tree it gets, which is exaggerated on small screens.
Start by closing your container divs before opening another. Also, use consistent indentation - that will help make this issue more obvious when you're reading your code. I have cleaned up your code and changed nothing except the HTML markup. The top example in the linked pen has cleaned up markup, while the bottom example has the containers grouped.
https://codepen.io/the_Northway/pen/QWqapbg?editors=1100
.portfolio {
background-color: lightblue;
display: flex;
flex-direction: column;
align-items: center;
}
.portfolio#portfolio_fixed {
background-color: orange;
}
.portfolio h1 {
font-style: 500px;
}
.portfolio ul {
margin: 10px;
padding: 0;
list-style: none;
display: flex;
}
.portfolio ul li {
font-size: 14px;
margin-right: 9px;
padding: 7px;
border-radius: 10px;
cursor: pointer;
}
.portfolio ul li.active {
background-color: #445566;
color: white;
}
.portfolio .container {
width: 70%;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.portfolio .container .item {
width: 220px;
height: 150px;
border-radius: 20px;
border: 1px solid #f0eaea;
margin: 10px 20px;
display: flex;
align-items: center;
justify-content: center;
color: white;
position: relative;
}
.portfolio .container .item h3 {
position: absolute;
font-style: 20px;
}
.portfolio .container .item img {
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
z-index: 1;
}
.portfolio .container .item:hover {
background-color: #445566;
}
.portfolio .container .item:hover img {
opacity: 0;
z-index: 0;
}
<div class="portfolio" id="portfolio_fixed">
<h1>Portfolio</h1>
<ul>
<li class="active">Featured</li>
<li>Web app</li>
<li>Mobile app</li>
<li>Design</li>
<li>Branding</li>
</ul>
<div class="container">
<div class="item">
<img src="assets/default-product-image.png" alt="" />
<h3>Coming soon</h3>
</div>
</div>
<div class="container">
<div class="item">
<img src="assets/default-product-image.png" alt=""/>
<h3>Coming soon</h3>
</div>
</div>
<div class="container">
<div class="item">
<img src="assets/default-product-image.png" alt=""/>
<h3>Coming soon</h3>
</div>
</div>
</div>
<div class="portfolio" id="portfolio_broken">
<h1>Portfolio</h1>
<ul>
<li class="active">Featured</li>
<li>Web app</li>
<li>Mobile app</li>
<li>Design</li>
<li>Branding</li>
</ul>
<div class="container">
<div class="item">
<img src="assets/default-product-image.png" alt="" />
<h3>Coming soon</h3>
</div>
<div class="container">
<div class="item">
<img src="assets/default-product-image.png" alt=""/>
<h3>Coming soon</h3>
</div>
<div class="container">
<div class="item">
<img src="assets/default-product-image.png" alt=""/>
<h3>Coming soon</h3>
</div>
</div>
</div>
</div>
</div>

Flex parent doesn't expand to height of child

This might be a bit of an amateur question as I'm just getting started with using Flexbox, but I'm having trouble creating the following layout.
https://jsfiddle.net/wp6hsnjo/
I'm aiming to have two rows (Main on top and Footer on the bottom) then 3 columns within Main, the first and last being fixed with the center column filling the remaining space. The difficulty I'm having is that the Main container won't inherit the height of the child elements.. which leaves the sticky footer in limbo. Is there a way that I can get the Main div to expand to match the height of the child elements? I've tried playing around with overflow and height settings but to no success.
html, body {
height: 100%;
}
body {
margin:0;
padding:0;
background-color: #f4f3f0;
box-sizing: border-box;
font-family: arimo, sans-serif;
color: #555760;
}
#container {
max-width:1560px;
margin: 0 auto;
display: flex;
flex-flow: wrap;
min-height: 100vh;
flex-direction: column;
}
#main {
display: flex;
flex: 1 0 auto;
height:auto;
}
header {
padding:30px;
flex: 0 0 100px;
order: 1;
}
#logo-container {
}
.logo {
width:75px;
margin-top:5px;
position:fixed;
}
nav {
width:100px;
text-align: right;
flex: 0 0 100px;
order: 3;
padding:30px;
}
nav ul {
list-style-type: none;
width:100px;
margin: 0;
padding: 0;}
.main-nav {
position:fixed;
text-transform: uppercase;
font-size: 12px;
font-weight: 700;
color: #222;
letter-spacing: 0.3px;
}
.main-nav li {
margin-bottom:7px;
}
.social-media {
position: fixed;
bottom:0;
margin-bottom:40px;
text-align: right;
width: 100px;
}
.social-media-icons {
width:16px;
height:16px;
margin-bottom:18px;
}
#page-content {
margin:30px 0 60px 0;
flex: 1;
order: 2;
}
.portfolio {
display: flex;
flex-wrap: wrap;
padding-bottom:300px;
}
.square {
position: relative;
flex-basis: calc(33.333% - 10px);
margin: 5px;
border: 1px solid #ccc;
box-sizing: border-box;
}
.span2 {
position: relative;
flex-basis: calc(66.666% - 10px);
margin: 5px;
border: 1px solid #ccc;
box-sizing: border-box;
}
.square::before {
content: '';
display: block;
padding-top: 100%;
}
.square .content {
position: absolute;
top: 0; left: 0;
height: 100%;
width: 100%;
}
footer {
order: 2;
margin: 0 0 58px 30px;
flex-shrink: 0;
font-size: 12px;
}
.hidden {
opacity: 0;
}
#keyframes fade-in {
from {opacity: 0;}
to {opacity: 1;}
}
.fade-in-element {
animation: fade-in 1.4s;
}
<div id="container"> <!-- CONTAINER -->
<div id="main">
<header> <!-- HEADER -->
<div id="logo-container">
<img src="images/icons/logo-black.png" alt="Logo" class="logo">
</div>
</header> <!-- HEADER END -->
<nav>
<ul class="main-nav">
<li>Home</li>
<li>Archive</li>
<li>About</li>
<li>Contact</li>
</ul>
<ul class="social-media">
</ul>
</nav>
<section id="page-content"> <!-- PAGE CONTENT -->
<div class="portfolio">
<div class="span2">
<div class="content">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="span2">
<div class="content">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
</div>
</section> <!-- PAGE CONTENT END -->
</div><!-- MAIN END -->
<footer class="hidden" > <!-- FOOTER -->
<div id="copyright">© 2020 this is the footer</div>
</footer> <!-- FOOTER END -->
</div> <!-- CONTAINER END -->
Removing flex-flow: wrap from your #container element does the trick, and removing the 300px bottom padding from the .portfolio element to prevent a bunch of extra space.
var animateHTML = function() {
var elems;
var windowHeight;
function init() {
elems = document.querySelectorAll('.hidden');
windowHeight = window.innerHeight;
addEventHandlers();
checkPosition();
}
function addEventHandlers() {
window.addEventListener('scroll', checkPosition);
window.addEventListener('resize', init);
}
function checkPosition() {
for (var i = 0; i < elems.length; i++) {
var positionFromTop = elems[i].getBoundingClientRect().top;
if (positionFromTop - windowHeight <= 0) {
elems[i].className = elems[i].className.replace(
'hidden',
'fade-in-element'
);
}
if ((positionFromTop - windowHeight > 1) || (positionFromTop < 0)) {
elems[i].className = elems[i].className.replace(
'fade-in-element',
'hidden'
);
}
}
}
return {
init: init
};
};
html, body {
height: 100%;
}
body {
margin:0;
padding:0;
background-color: #f4f3f0;
box-sizing: border-box;
font-family: arimo, sans-serif;
color: #555760;
}
#container {
max-width:1560px;
margin: 0 auto;
display: flex;
min-height: 100vh;
flex-direction: column;
}
#main {
display: flex;
flex: 1 0 auto;
}
header {
padding:30px;
flex: 0 0 100px;
order: 1;
}
#logo-container {
}
.logo {
width:75px;
margin-top:5px;
position:fixed;
}
nav {
width:100px;
text-align: right;
flex: 0 0 100px;
order: 3;
padding:30px;
}
nav ul {
list-style-type: none;
width:100px;
margin: 0;
padding: 0;}
.main-nav {
position:fixed;
text-transform: uppercase;
font-size: 12px;
font-weight: 700;
color: #222;
letter-spacing: 0.3px;
}
.main-nav li {
margin-bottom:7px;
}
.social-media {
position: fixed;
bottom:0;
margin-bottom:40px;
text-align: right;
width: 100px;
}
.social-media-icons {
width:16px;
height:16px;
margin-bottom:18px;
}
#page-content {
margin:30px 0 60px 0;
flex: 1;
order: 2;
}
.portfolio {
display: flex;
flex-wrap: wrap;
}
.square {
position: relative;
flex-basis: calc(33.333% - 10px);
margin: 5px;
border: 1px solid #ccc;
box-sizing: border-box;
}
.span2 {
position: relative;
flex-basis: calc(66.666% - 10px);
margin: 5px;
border: 1px solid #ccc;
box-sizing: border-box;
}
.square::before {
content: '';
display: block;
padding-top: 100%;
}
.square .content {
position: absolute;
top: 0; left: 0;
height: 100%;
width: 100%;
}
footer {
order: 2;
margin: 0 0 58px 30px;
flex-shrink: 0;
font-size: 12px;
}
.hidden {
opacity: 0;
}
#keyframes fade-in {
from {opacity: 0;}
to {opacity: 1;}
}
.fade-in-element {
animation: fade-in 1.4s;
}
<body onload="animateHTML().init();">
<div id="container"> <!-- CONTAINER -->
<div id="main">
<header> <!-- HEADER -->
<div id="logo-container">
<img src="images/icons/logo-black.png" alt="Logo" class="logo">
</div>
</header> <!-- HEADER END -->
<nav>
<ul class="main-nav">
<li>Home</li>
<li>Archive</li>
<li>About</li>
<li>Contact</li>
</ul>
<ul class="social-media">
</ul>
</nav>
<section id="page-content"> <!-- PAGE CONTENT -->
<div class="portfolio">
<div class="span2">
<div class="content">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="span2">
<div class="content">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
<div class="square">
<div class="content spread">
</div>
</div>
<div class="square">
<div class="content column">
</div>
</div>
</div>
</section> <!-- PAGE CONTENT END -->
</div><!-- MAIN END -->
<footer class="hidden" > <!-- FOOTER -->
<div id="copyright">© 2020 this is the footer</div>
</footer> <!-- FOOTER END -->
</div> <!-- CONTAINER END -->
</body>

How can I prevent my columns from stacking when the browser viewport shrinks

Instead of having my columns from stacking when the browser viewport shrinks, I want the columns to remain as they are but have a horizontal scroll bar to appear so people on smaller devices can just swipe right to scroll.
Is this possible since I am using flex?
body {
color: #333;
font-family: Helvetica Neue,Arial,Helvetica,sans-serif;
font-size: 14px;
line-height: 20px;
font-weight: 400;
}
.board-container {
background-color: rgb(0, 121, 191);
height: 100%;
position: relative;
background-size: cover;
overflow: hidden;
}
#board-surface {
display: flex;
flex-direction: column;
}
#board-surface, body, html {
height: 100%;
}
#content {
flex-grow: 1;
overflow-y: auto;
outline: none;
}
.board-wrapper {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.board-main-content {
height: 100%;
display: flex;
flex-direction: column;
margin-right: 0;
transition: margin .1s ease-in;
}
.board-canvas {
position: relative;
flex-grow: 1;
}
/*#board {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
white-space: nowrap;
margin-bottom: 8px;
overflow-x: auto;
overflow-y: hidden;
padding-bottom: 8px;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}*/
.list-wrapper {
width: 272px;
margin: 0 4px;
height: 100%;
box-sizing: border-box;
display: inline-block;
vertical-align: top;
white-space: nowrap;
background-color: #cccccc;
}
.list {
background: #e2e4e6;
border-radius: 3px;
box-sizing: border-box;
display: flex;
flex-direction: column;
max-height: 100%;
position: relative;
white-space: normal;
}
.list-card {
background-color: #fff;
border-radius: 3px;
box-shadow: 0 1px 0 #ccc;
cursor: pointer;
display: block;
margin-bottom: 8px;
max-width: 300px;
min-height: 20px;
position: relative;
text-decoration: none;
z-index: 0;
}
<html>
<head>
<title></title>
</head>
<body>
<div class="board-container">
<div class="board-inner">
<div id="board-surface">
<div id="header">
main header goes here
</div>
<div id="content">
<div class="board-wrapper">
<div class="board-main-content">
<div class="board-header">board header</div>
<div class="board-canvas">
<div id="board">
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
<div class="list-wrapper">
<div class="list">
<div class="list-header">list header</div>
<div class="list-cards">
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
<div class="list-card">
this is a list card
</div>
</div>
</div>
</div> <!-- /list-wrapper -->
</div> <!-- /board-->
</div>
</div>
</div>
</div>
<div id="footer">
</div>
</div>
</div>
</div>
</body>
</html>
DEMO: https://codepen.io/anon/pen/wxJGMx?editors=0110
I was able to achieve a horizontal scroll on flex container. I've given min-width to .list-wrapper and have added the below styles to #board item:
.list-wrapper {
min-width: 272px;
width: 272px;
margin: 0 4px;
height: 100%;
box-sizing: border-box;
display: inline-block;
vertical-align: top;
white-space: nowrap;
background-color: #cccccc;
}
#board {
display: flex;
overflow: scroll;
}

Displaying content below a fixed header

My page has a fixed header, I am aware that this causes content flows to begin at the top of the page. I've been searching for a workaround for this and nothing seems to be working, for example this one
Below is the code and here is a codepen - As you can see the content in my article is being displayed at the top of the page, although it is place at the bottom of my html.
I'd appreciate an explained workaround so that I can LEARN.
UPDATE - adding padding-top:{500px} successfully fixed this issue. Is this a recommended workaround? I was made aware of this fix here.
Thanks guys!
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
}
.col-1 {
width: 100%;
}
.inline-block-container>* {
display: -moz-inline-stack;
display: inline-block;
}
ul,
ol {
list-style: none;
margin: 0px;
padding: 0px;
}
.wrapper {
position: fixed;
height: 100px;
width: 100%;
top: 0;
z-index: 99;
}
.header {
width: 100%;
top: 0;
border-bottom: 1px solid #ddd;
background-color: white;
display: -webkit-flex;
display: flex;
-webkit-justify-content: space-between;
justify-content: space-between;
}
.header .logo a img {
width: 150px;
height: 49px;
}
.logo {
margin-left: 40px;
}
.menu li {
padding-right: 50px;
margin-right: 20px;
}
.header .menu ul {
margin: 0;
padding: 0;
}
.header .menu ul li {
display: inline-block;
list-style: none;
}
.header .menu ul li a {
text-decoration: none;
display: block;
padding: 30px 20px;
}
.site-content {
margin-top: 100px;
}
.banner-home {
background: url("");
height: 100vh;
width: 100%;
background-size: cover;
position: absolute;
z-index: -1000;
}
#intro {
position: absolute;
top: 70%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
text-align: center;
color: #020000;
z-index: 50;
}
#intro a {
border: 3px solid #020000;
cursor: pointer;
}
#intro li a {
padding: 20px;
color: #020000;
font-weight: 800;
}
#intro li a:hover {
background-color: #ffd800;
}
<div id="page" class="rare-site">
<div class="wrapper">
<div id="global-navigation">
<!-- Global Header -->
<header class="header">
<div class="logo">
<a href="">
<!--<img src="images/rare-logo.png">-->
<h1>Rare Select</h1>
</a>
</div>
<nav class="menu">
<ul>
<li>HOME</li>
<!--
-->
<li>
<div class="flexbox-container">
INFO
</li>
<!--
-->
<li>
<div class="flexbox-container">
NEWSLETTER
</div>
<!--
-->
<li>
<div class="flexbox-container">
CONTACT
</li>
<!--
-->
</ul>
</header>
</div>
</div>
<div id="content" class="site-content">
<div id="primary" class="content-area">
<!-- Content Area -->
<main id="main" class="site-main" role="main">
<div class="banner large-trunk">
<div class="banner-home"></div>
<div class="banner-overlay">
<div id="intro">
<h2 class="discover"><u>The easy way to discover models.</u></h2>
<div id="button-container">
<div id="button-overlay">
<ul class="inline-block-container">
<li><a class="discover-1">I'm looking to become a model</a></li>
<li><a class="discover-2">I'm looking for a model</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<article id="newsletter">
<div class="newsletter-entry">
<section class="news-content trunk">
<div class="feature-box">
<h2>Recent News</h2>
</div>
</section>
</div>
</article>
</main>
</div>
</div>
</div>
You already have a 100px header and a margin-top applied to site-content for the content following it, as is usually done.
A position: fixed header will be taken out of the flow. So the DOM element following it will overlap.
A z-index higher that the surrounding content is given so that it comes on top (which you have done giving wrapper a z-index: 99)
The content following it is given a margin-top value. If the height of the header is fixed (as is the case here) you give it using CSS, if the height of the header is dynamic, you might have to opt for javascript to set the height dynamically.
So restrict the heights of #global-navigation and .header using height: 100% and add display: flex to the navigation ul. Also remove the absolute positioning of the banner and apply background image to site-content- see demo below:
*,
*:before,
*:after {
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
}
.col-1 {
width: 100%;
}
.inline-block-container>* {
display: -moz-inline-stack;
display: inline-block;
}
ul,
ol {
list-style: none;
margin: 0px;
padding: 0px;
}
.wrapper {
position: fixed;
height: 100px;
width: 100%;
top: 0;
z-index: 99;
}
#global-navigation { /* ADDED */
height: 100%;
}
.header {
height: 100%; /* ADDED */
width: 100%;
top: 0;
border-bottom: 1px solid #ddd;
background-color: white;
display: -webkit-flex;
display: flex;
-webkit-justify-content: space-between;
justify-content: space-between;
}
.header .logo a img {
width: 150px;
height: 49px;
}
.site-content { /* ADDED */
background: url("http://placehold.it/50x50");
height: 100vh;
width: 100%;
background-size: cover;
}
.logo {
margin-left: 40px;
}
.menu li {
padding-right: 50px;
margin-right: 20px;
}
.header .menu ul {
display: flex; /* ADDED */
margin: 0;
padding: 0;
}
.header .menu ul li {
display: inline-block;
list-style: none;
}
.header .menu ul li a {
text-decoration: none;
display: block;
padding: 30px 20px;
}
.site-content {
margin-top: 100px;
}
.banner-home {} /* removed absolute positioning */
#intro { /* removed absolute positioning */
width: 100%;
text-align: center;
color: #020000;
z-index: 50;
}
#intro a {
border: 3px solid #020000;
cursor: pointer;
}
#intro li a {
padding: 20px;
color: #020000;
font-weight: 800;
}
#intro li a:hover {
background-color: #ffd800;
}
<div id="page" class="rare-site">
<div class="wrapper">
<div id="global-navigation">
<!-- Global Header -->
<header class="header">
<div class="logo">
<a href="">
<!--<img src="images/rare-logo.png">-->
<h1>Rare Select</h1>
</a>
</div>
<nav class="menu">
<ul>
<li>HOME</li>
<!--
-->
<li>
<div class="flexbox-container">
INFO
</div>
</li>
<!--
-->
<li>
<div class="flexbox-container">
NEWSLETTER
</div>
<!--
-->
<li>
<div class="flexbox-container">
CONTACT
</div>
</li>
<!--
-->
</ul>
</nav>
</header>
</div>
</div>
<div id="content" class="site-content">
<div id="primary" class="content-area">
<!-- Content Area -->
<main id="main" class="site-main" role="main">
<div class="banner large-trunk">
<div class="banner-home"></div>
<div class="banner-overlay">
<div id="intro">
<h2 class="discover"><u>The easy way to discover models.</u></h2>
<div id="button-container">
<div id="button-overlay">
<ul class="inline-block-container">
<li><a class="discover-1">I'm looking to become a model</a></li>
<li><a class="discover-2">I'm looking for a model</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<article id="newsletter">
<div class="newsletter-entry">
<section class="news-content trunk">
<div class="feature-box">
<h2>Recent News</h2>
</div>
</section>
</div>
</article>
</main>
</div>
</div>
</div>

Flexbox product grid not works

I have a product grid with Bootstrap and I added flexbox styles for the products .item box have same height.
You can check the grid here:
https://jsfiddle.net/oet3c3dp/2/
I add the basic flexbox styles, for the parent element .product-list:
.product-list {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-justify-content: space-between;
justify-content: space-between;
}
And then I added the styles for the child's elements:
.product-list .item {
padding: 0 10px 10px 0px;
margin-left: 0;
float: left;
text-align: center;
-webkit-flex: 0 0 auto;
flex: 0 0 auto;
}
Why this not works fine?
You are missing classes .container and .row (which they are part of the bootstrap grid), plus you need to change your flex: 0 0 auto to flex:1
.product-list {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-justify-content: space-between;
justify-content: space-between;
}
.product-list .item {
padding: 0 10px 10px 0px;
margin-left: 0;
float: left;
text-align: center;
-webkit-flex: 1;
flex: 1;
}
.product-list .color-swatch {
width: 16px;
height: 16px;
border: 1px solid;
border-color: #d8d9db;
display: inline-block;
vertical-align: middle;
-webkit-border-top-right-radius: 50%;
border-top-right-radius: 50%;
-webkit-border-bottom-right-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
border-bottom-left-radius: 0;
-webkit-border-top-left-radius: 0;
border-top-left-radius: 0;
-webkit-border-radius: 50%;
border-radius: 50%;
background-clip: padding-box;
-webkit-box-shadow: 0 3px 8px -5px black inset, -3px -1px 8px -4px white inset;
box-shadow: 0 3px 8px -5px black inset, -3px -1px 8px -4px white inset;
}
.product-list h3 {
font-size: 14px;
margin: 0px;
text-transform: uppercase;
margin-top: 2px;
}
.item-inner {
position: relative;
padding: 0 18px;
border: 1px solid #e0e0e0;
background-color: #fff;
/*min-height: 300px*/
}
.product-img {
padding-top: 10px;
text-align: center;
/* min-width: 210px;
height: 220px;*/
overflow: hidden;
/*width: 170px;*/
}
.product-info {
position: relative;
/*height: 73px;*/
padding-top: 20px;
}
.product-info span.extra-info {
display: block;
color: #455A64;
font-size: 12px;
}
.product-img img {
display: inline-block;
vertical-align: middle;
/* max-width: 210px;
max-height: 210px;*/
}
.product-list .item .price {
color: #37474F;
font-weight: 700;
font-size: 18px;
margin-right: 10px;
}
.product-list .item .product-id {
color: #455A64;
}
.product-list .item-inner:hover {
box-shadow: 0 3px 6px 0 rgba(51, 51, 51, .2);
}
.product-list .item a:hover {
color: #651fff;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="product-list row">
<div class="item col-xs-6 col-sm-3">
<div class="item-inner">
<a href="">
<div class="product-img">
<img class="img-responsive" src="http://rp-static.com/common/images/products_new/1728/1_m.jpg?dts={DPL_TS}" alt="">
</div>
<div class="product-info">
<div class="block">
<span class="price">9,95 €</span>
<span class="product-id">#1728</span>
</div>
<h3>TAZA CERAMICA</h3>
</div>
</a>
</div>
</div>
<div class="item col-xs-6 col-sm-3">
<div class="item-inner">
<a href="">
<div class="product-img">
<img class="img-responsive" src="http://rp-static.com/common/images/products_new/2100/1_m.jpg?dts={DPL_TS}" alt="">
</div>
<div class="product-info">
<div class="block">
<span class="price">16 €</span>
<span class="product-id">#2100</span>
</div>
<h3>MATRICULA MINI</h3>
</div>
</a>
</div>
</div>
<div class="item col-xs-6 col-sm-3">
<div class="item-inner">
<a href="">
<div class="product-img">
<img class="img-responsive" src="http://rp-static.com/common/images/products_new/2638/1_m.jpg?dts={DPL_TS}" alt="">
</div>
<div class="product-info">
<div class="block">
<span class="price">29 €</span>
<span class="product-id">#2638</span>
</div>
<h3>RELOJ PULSERA ZAC</h3>
</div>
</a>
</div>
</div>
<div class="item col-xs-6 col-sm-3">
<div class="item-inner">
<a href="">
<div class="product-img">
<img class="img-responsive" src="http://rp-static.com/common/images/products_new/5407/1_m.jpg?dts={DPL_TS}" alt="">
</div>
<div class="product-info">
<div class="block">
<span class="price">39 €</span>
<span class="product-id">#5407</span>
</div>
<h3>BOLSO VAQUERO PEQUEÑO</h3>
</div>
</a>
</div>
</div>
</div>
</div>

Resources