I have set up 3 flexbox containers, with one container controlling the other two. In the primary and secondary containers, I have placed 4 images and an h1 element together. Now, I'm trying to figure out how to move the h1 elements on top of the flex containers, outside of them. I am new to using flexbox so please bear with me as I experiment and learn.
You can view the code on JsFiddle here
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/framework.css">
<link href='https://fonts.googleapis.com/css?family=Electrolize' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="js/custom.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<title>NK Electrical LTD</title>
</head>
<body>
<div class="container">
<div class="primary">
<h1>Menu</h1>
<li class="flex-item1"><img src="img/electrical.png"></li>
<li class="flex-item1"><img src="img/emergency.png"></li>
<li class="flex-item1"><img src="img/homeappliances1.png"></li>
<li class="flex-item1"><img src="img/homeappliances2.png"></li>
</div>
<div class="secondary">
<h1>Our latest products</h1>
<li class="flex-item"><img src="img/1.jpg"></li>
<li class="flex-item"><img src="img/2.jpg"></li>
<li class="flex-item"><img src="img/3.jpg"></li>
<li class="flex-item"><img src="img/4.jpg"></li>
</div>
</div>
</body>
</html>
Here is the relevant CSS code in the framework.css file:
*{
box-sizing: border-box;
margin:0;
padding: 0;
}
body{font-family: 'Electrolize', sans-serif;}
ul{list-style: none;padding: 0;margin: 0;}
.container{display: flex;flex-direction: column;}
.primary{display: flex;flex-wrap: wrap;justify-content: center;background-color:#1c1c1c;margin:0% 25%;padding:1%;}
.secondary{display: flex; flex-wrap: wrap;;justify-content: center;background-color:#1c1c1c;margin:0% 25%;padding:1%;}
.flex-item {
background-color: black;
padding: 5px;
width: 200px;
height: 150px;
margin-top: 10px;
line-height: 150px;
color: white;
font-weight: bold;
font-size: 3em;
text-align: center;
}
.flex-item1{
background-color: tomato;
padding: 5px;
width: 200px;
height: 150px;
margin-top: 10px;
line-height: 150px;
color: white;
font-weight: bold;
font-size: 3em;
text-align: center;
}
h1{flex:1;color:white;font-size:1.5em;font-weight: 300;border-bottom: 3px solid white;margin-bottom: 5%;padding:2%;margin-top:0;}
img{width:100px; height:auto;}
div{list-style: none;}