I'm making a mobile responsive page and I'm using flexbox for the first time.
The problem that I have is when there is a lot of information in the content div the div stretches very wide out of the page width.
I've tried using max-width styles and that takes away the responsiveness of the site.
JSFiddle
https://jsfiddle.net/z23rmo80/
CSS
body {
display: flex;
flex-direction: column;
min-height: 100vh;
text-align: center;
}
body .header {
width: 100%;
height: 182px;
background: white;
}
body .holygrail-body {
flex: 1 0 auto;
display: flex;
width:1000px;
margin-right:auto;
margin-left:auto;
}
body .holygrail-body .content {
flex: 1 0 auto;
background: lightgreen;
overflow-y: auto;
}
body .holygrail-body .nav {
width: 240px;
list-style: none;
text-align: left;
order: -1;
margin: 0;
}
body .holygrail-body .aside {
width: 100px;
background: orange;
}
body .footer {
width: 100%;
height: 60px;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #fff;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a:hover {
color: #f1f1f1;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
.mobile-header{display: none;}
.hamburger{display: none;}
ul, ol {
margin-top:10px;
}
.nav li {
list-style: none outside none;
line-height: 36px;
margin-left:-15px;
}
.nav li a {
color: #5f141f;
text-decoration: none;
text-shadow: 2px 1px #f6eaec;
font-size: 18px;
margin-left:-15px;
}
.sidenav li {
list-style: none outside none;
line-height: 36px;
margin-left:-15px;
}
.sidenav li a {
color: #5f141f;
text-decoration: none;
text-shadow: 2px 1px #f6eaec;
font-size: 18px;
margin-left:-15px;
}
@media (max-width: 700px) {
body .holygrail-body {
flex-direction: column;
}
body .holygrail-body .nav, body .holygrail-body .aside {
width: 100%;
}
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
.hamburger{display: inline;margin-left:-900px;}
.nav{display: none;}
.mobile-header{display: inline;}
.header{display: none;}
}
HTML
<header class="header">
<img src="header.jpg" style="max-width:1848px; margin-right:auto;margin-left:auto;" alt="">
</header>
<header class="mobile-header">
<img src="header.jpg" style="width:100%;max-width:1848px; margin-right:auto;margin-left:auto;" alt="">
</header>
<div class="holygrail-body">
<span class="hamburger" style="font-size:30px;cursor:pointer" onclick="openNav()">☰ Menu</span>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">New Items</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
</ul>
</div>
<div class="content">
<h1>Test</h1>
</div>
<ul class="nav">
<li><a href="#">Home</a></li>
<li><a href="#">New Items</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
<li><a href="#">Information Page</a></li>
</ul>
</div>
<footer class="footer">?2017</footer>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…