Here is a top menu:
When browser width is < 1000px, I would like to :
Hide the 3 top-right <input> fields (I achieved it with display:none in the media query)
The "Post" button now becomes a button that opens a collapsible menu with the 3 input fields now displayed one after another in a new line, like this:
But I think this would require to completely change the DOM element order with CSS / media query. Is this possible / needed here?
How would you implement such top menu collapsible menu?
* { margin: 0; padding: 0; }
a { text-decoration: none; }
img { border: 0; }
body { overflow: hidden; height: 100%; font-family: arial; }
#header { border-bottom: 1px solid #dedede; height: 60px; margin: 0; display: -ms-flexbox; display: -webkit-flex; display: flex; }
#topleft { border-right: 1px solid #dedede; padding: 0px; float: left; -ms-flex: 0 0 155px; -webkit-flex: 0 0 155px; flex: 0 0 155px; height:100%; }
#topmid { border-right: 1px solid #dedede; float: left; -ms-flex: 0 0 40%; -webkit-flex: 0 0 40%; flex: 0 0 40%; height:100%; transition: all 0.3s ease-in-out; }
#topright { -ms-flex: 1; -webkit-flex: 1; flex: 1; position: relative; }
#logo { color: #ff0048; font-family: arial; font-size: 1.625em; font-weight: bold; padding-top: 14px; padding-left: 7px; }
#snif { margin-left: 0px; border: 0; margin-top: 22px; outline: 0px !important; width: calc(100% - 55px);}
#searchpng { background: #ffffff url("search.png") no-repeat left top; width: 40px; height: 30px; float:left; margin: 17 0 10 10px; }
.post { border: 1px solid #c4c4c4; padding: 5 2 5 10px; border-radius: 2px; }
#input1 { margin-left: 12px; width: calc(40% - 75px); position: relative; top:-7px; }
#input2 { margin-left: 0px; margin-top: 22px; width: calc(35% - 75px); position: relative; top:-7px; }
#input3 { width: calc(35% - 75px); position: relative; top:-7px; max-width: 230px;}
#deposer { background-color: #fb0149; color: white; padding: 6 10 5 10px; border-radius: 2px; position: relative; top:-7px; width: 65px; display: inline-block; text-align: center; margin-left: 5px; font-size: 0.875em; font-weight: bold; }
#spacer { max-width: 15px; width: calc(100% - 552px); display: inline-block; }
#media (max-width: 1000px) {
#topmid { -webkit-flex: 0 0 30%; -ms-flex: 0 0 30%; flex: 0 0 30%; }
body { overflow-y: scroll; }
}
<div id="header">
<div id="topleft" class="unselectable">
<div id="logo"><img src="logo.png" /></div>
</div>
<div id="topmid">
<div id="searchpng"></div>
<input type="text" placeholder="Lorem ipsum" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Lorem ipsum'" autocomplete="off" id="snif"></input>
</div>
<div id="topright" class="unselectable">
<input id="input1" class="post" type="textarea" placeholder="" autocomplete="off"/>
<input id="input2" class="post" type="textarea" placeholder="" autocomplete="off"/>
<input id="input3" class="post unselectable" placeholder="" value="" autocomplete="off"/>
Post
</div>
</div>
<div>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
I would just change the position of the current menu on the media query for <1000px.
You could also create new html elements and set them to display:none until the media query is activated, and set them to display:block or whatever you wanted.
added html:
<div id="mobile-topright" class="unselectable">
<input id="input1" class="post" type="textarea" placeholder="" autocomplete="off"/></div>
<input id="input2" class="post" type="textarea" placeholder="" autocomplete="off"/>
<input id="input3" class="post unselectable" placeholder="" value="" autocomplete="off"/>
Post
</div>
added CSS:
#media (max-width: 1000px) {
#topmid { -webkit-flex: 0 0 30%; -ms-flex: 0 0 30%; flex: 0 0 30%; }
body { overflow-y: scroll; }
#topright {display:none;}
#mobile-topright {margin-top:5%;
}
#input1, #input2, #input3 {width:60%;
max-width:60%;
margin:0 auto;
padding:5px;}
}
Related
I am trying to make the search bar expand on device size < 768px. GIF Image.
How to fixed button when I click expand?
#media (max-width: 768px) {
.header-search {
margin-left: 1em;
.search-bar {
max-width: 3em;
margin-left: auto;
&:focus-within {
max-width: 100%;
.search-bar__input {
width: auto;
padding: 0 1em;
}
}
}
.search-bar__input {
width: 0;
padding: 0;
}
}
}
Here is my codepen:
https://codepen.io/phamtien990819/pen/PoqGwEv
I suggest remove the line width:auto in &:focus-within .search-bar__input.
Moreover, you can add padding transition to .search-bar__input to make the transition smoother
#media (max-width: 768px) {
.header-search {
margin-left: 1em;
.search-bar {
max-width: 3em;
margin-left: auto;
&:focus-within {
max-width: 100%;
.search-bar__input {
/*Remove width: auto*/
padding: 0 1em;
}
}
}
.search-bar__input {
width: 0;
padding: 0;
/*Add padding transition*/
transition: padding 3s
}
.search-bar__btn { }
}
}
This CSS code I updated. I used position: absolute; to place button on right of the bar. So even after input is opened button stays on right without moving.
#media (max-width: 768px) {
.header-search {
margin-left: 1em;
position: relative;
.search-bar__input {
margin-left: 10px;
background: transparent;
overflow: hidden;
}
.search-bar__btn {
width: 40px;
position: absolute;
right: 1px;
height: 29px;
}
body {
display: flex;
flex-direction: column;
margin: 0;
min-height: 100vh;
font-size: 14px;
}
ol,
ul {
padding: 0;
margin: 0;
list-style: none;
}
main {
flex: 1;
}
.material-icons {
font-size: 24px;
vertical-align: middle;
}
.material-icons::before {
content: attr(icon);
}
.site-header {
position: sticky;
top: -40px;
width: 100%;
z-index: 99;
background: #fff;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
.top-nav {
background: rgba(0, 0, 0, 0.03);
}
.top-nav .container {
display: flex;
justify-content: space-between;
align-items: center;
height: 40px;
}
.top-nav ul {
display: flex;
font-size: 12px;
list-style: none;
}
.top-nav ul>li+li {
margin-left: 1.5em;
}
.top-nav ul a {
color: currentColor;
}
.main-nav .container {
display: flex;
justify-content: space-between;
align-items: center;
height: 5em;
}
.header-brand {
display: flex;
align-items: center;
justify-content: space-between;
}
.header-brand .logo {
text-decoration: none;
color: currentColor;
}
.header-brand .menu-toggle {
display: none;
border: 0;
outline: 0;
background: transparent;
margin-left: 1em;
padding: 6px;
}
/* BEGIN SEARCH BAR */
.header-search {
flex: auto;
margin-left: 4em;
}
.header-search .search-bar {
display: flex;
align-items: center;
border: 1px solid rgba(0, 0, 0, 0.1);
max-width: 25em;
height: 2.5em;
transition: all 3s;
}
.header-search .search-bar__input {
flex: auto;
height: 100%;
border: 0;
padding: 0 1em;
outline: 0;
}
.header-search .search-bar__btn {
width: 3em;
height: 100%;
border: 0;
outline: 0;
text-align: center;
}
#media (max-width: 768px) {
.header-search {
margin-left: 1em;
position: relative;
}
.header-search .search-bar__input {
margin-left: 10px;
background: transparent;
overflow: hidden;
}
.header-search .search-bar__btn {
width: 40px;
position: absolute;
right: 1px;
height: 29px;
}
.header-search .search-bar {
max-width: 3em;
margin-left: auto;
}
.header-search .search-bar:focus-within {
max-width: 100%;
}
.header-search .search-bar:focus-within .search-bar__input {
width: auto;
}
.header-search .search-bar__input {
width: 0;
padding: 0;
}
}
/* END SEARCH BAR */
.header-user {
display: flex;
align-items: center;
}
.header-user .item {
position: relative;
flex-shrink: 0;
display: inline-flex;
}
.header-user .item .user-link {
font-weight: 500;
color: currentColor;
padding: 6px;
border-radius: 4px;
margin-left: 8px;
}
.header-user .item .user-link:hover {
text-decoration: none;
background-color: rgba(0, 0, 0, 0.03);
}
#media (max-width: 768px) {
.s-header {
top: 0;
}
.top-nav {
display: none;
}
.main-nav .container {
height: 4em;
}
.header-brand .menu-toggle {
display: inline-block;
margin-left: 0;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<body>
<header class="site-header">
<div class="top-nav">
<div class="container">
<ul>
<li>Top menu item</li>
<li>Top menu item</li>
<li>Top menu item</li>
<li>Top menu item</li>
<li>Top menu item</li>
</ul>
</div>
</div>
<nav class="main-nav">
<div class="container">
<div class="header-brand">
<a class="logo d-none d-md-inline-block" href="#">LOGO HERE</a>
<button class="menu-toggle">
<i class="material-icons" icon="menu"></i>
</button>
</div>
<div class="header-search">
<form action="#" class="search-bar">
<input class="search-bar__input" type="search" placeholder="Search..." />
<button class="search-bar__btn" type="button">
<i class="material-icons" icon="search"></i>
</button>
</form>
</div>
<ul class="header-user">
<li class="item">
<a class="user-link" href="#">
<i class="material-icons" icon="person_add"></i>
<span class="d-none d-md-inline">Login / Register</span>
</a>
</li>
</ul>
</div>
</nav>
</header>
<main>
<div class="container" style="height: 1000px">
<p class="mt-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</main>
<footer>
<div class="container">
<p>Footer content</p>
</div>
</footer>
</body>
First post using Stackflow, and super excited to be starting off on my web development career, I am using Foundation 6 to build out my first website and was hoping someone could point out some key aspects of my code that would allow it to become more responsive.. Any help would be greatly appreciated as I am new to all of this!
Thanks!
/* Left Header Block */
.header-left-block {
background-image: url('../img/abstract_header_left.jpg');
background-size: cover;
background-repeat: no-repeat;
height: 100vh;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
.brand-title {
font-size: 75px;
position: relative;
color: #fff;
padding: 0px;
margin: auto;
padding-top: 260px;
font-family: poppins-Extralight;
}
/* Right Header Block */
.header-right-block {
background-color: #FCDA02;
background-repeat: no-repeat;
height: 100vh;
z-index: -2;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
}
.header-right-content {
}
.slash {
font-size: 125px;
color: #fff;
padding: 400px 0px;
}
.sub-header {
color: #fff;
font-size: 30px;
font-family: poppins-bold;
}
.search-text {
font-family: poppins-regular;
color: #fff;
display: inline-block;
padding: 25px 10px;
}
.top-btns {
height: auto;
display: inline-block;
position: absolute;
right: 0;
top: 0;
padding: 5px 30px;
}
/* Section Two */
.section-two {
background-color:;
height: 1000px;
width: 100%;
position: relative;
box-sizing: border-box;
padding: 50px;
margin-bottom: 100px;
}
.section-two:after {
position: absolute;
width: 100%;
height: 100%;
content: '';
background: #00ACC2;
top: 0;
bottom: 0;
right: 0;
left: 0;
transform-origin:;
transform: skewY(-30deg);
margin-top: -8px;
z-index: -1;
}
.section-two-container {
padding-bottom: 400px;
align-content: flex-start;
}
.number {
font-size: 20vw;
color: #fff;
font-family: poppins-mediumitalic;
}
.item-text {
text-align: left;
font-size: 2vh;
color: #fff;
padding: 2px;
}
.sub-header-one {
color: #fff;
font-size: 5vh;
font-family: poppins-bold;
text-align: left;
}
.squiggel {
z-index: 1;
}
/* Section Three */
.section-three {
background-color:;
height: 1200px;
width: 100%;
position: relative;
box-sizing: border-box;
padding: 50px;
margin-top: 0px;
}
.section-three:after {
position: absolute;
width: 100%;
height: 100%;
content: '';
background: #83C200;
top: 0;
bottom: 0;
right: 0;
left: 0;
transform-origin: top right;
transform: skewY(30deg);
z-index: -1;
}
.section-three-content {
margin-top: -1500px;
}
.iphone {
padding-left: 100px;
}
/* Section Four */
.section-four {
background-color:#111;
height: 1200px;
width: 100%;
position: relative;
box-sizing: border-box;
padding: 50px;
margin-top: -800px;
}
/* Menu */
/* Media Queries */
#media only screen and (max-width: 630px) {
.section-two-container {
margin-top: -200px;
}
.section-three-content {
margin-top: -100px;
}
.section-four {
margin-top: -225px;
}
.sub-header-one {
font-size: 4vh;
}
.number {
}
}
/* Font */
#poppins-bold {
font-family: poppins-bold;
src: url(../fonts/Poppins-Bold.ttf);
}
#poppins-regular {
font-family: poppins-regular;
src: url(../fonts/Poppins-Regular.ttf);
}
#poppins-Extralight {
font-family: poppins-extralight;
src: url(../fonts/Poppins-ExtraLight.ttf);
}
#poppins-MediumItalic {
font-family: poppins-mediumitalic;
src: url(../fonts/Poppins-MediumItalic.ttf);
}
/* Mouse Scroll */
p {
margin-left: -55px;
}
#-webkit-keyframes ani-mouse {
0% {
opacity: 1;
top: 29%;
}
15% {
opacity: 1;
top: 50%;
}
50% {
opacity: 0;
top: 50%;
}
100% {
opacity: 0;
top: 29%;
}
}
#-moz-keyframes ani-mouse {
0% {
opacity: 1;
top: 29%;
}
15% {
opacity: 1;
top: 50%;
}
50% {
opacity: 0;
top: 50%;
}
100% {
opacity: 0;
top: 29%;
}
}
#keyframes ani-mouse {
0% {
opacity: 1;
top: 29%;
}
15% {
opacity: 1;
top: 50%;
}
50% {
opacity: 0;
top: 50%;
}
100% {
opacity: 0;
top: 29%;
}
}
.scroll-btn {
display: inline-block;
position: relative;
left: 0;
right: 0;
text-align: center;
margin-bottom: 50px;
z-index: 100;
}
.scroll-btn > * {
display: inline-block;
line-height: 18px;
font-size: 13px;
font-weight: normal;
color: #7f8c8d;
color: #ffffff;
font-family: "proxima-nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
letter-spacing: 2px;
}
.scroll-btn > *:hover,
.scroll-btn > *:focus,
.scroll-btn > *.active {
color: #ffffff;
}
.scroll-btn > *:hover,
.scroll-btn > *:focus,
.scroll-btn > *:active,
.scroll-btn > *.active {
opacity: 0.8;
filter: alpha(opacity=80);
}
.scroll-btn .mouse {
position: relative;
display: block;
width: 35px;
height: 55px;
margin: 0 auto 20px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
border: 3px solid white;
border-radius: 23px;
}
.scroll-btn .mouse > * {
position: absolute;
display: block;
top: 29%;
left: 50%;
width: 8px;
height: 8px;
margin: -4px 0 0 -4px;
background: white;
border-radius: 50%;
-webkit-animation: ani-mouse 2.5s linear infinite;
-moz-animation: ani-mouse 2.5s linear infinite;
animation: ani-mouse 2.5s linear infinite;
section class="grid-x align-middle section-two">
<section class="small-12 medium-5 section-two-container">
<div class="grid-x grid-container align-middle">
<div class="small-12 hide-for-small-only squiggel"><img src="img/red-squiggel.png" style=" height: 350px;"></div>
</div>
</section>
<section class="small-12 medium-7 section-two-container">
<div class="grid-x align-top grid-container ">
<div class="small-4 medium-4 large-5 flex-child-auto"><h1 class="number"> 1 </h1></div>
<div class="small-8 medium-8 large-7 flex-child-auto">
<h2 class="sub-header-one">website design and development</h2>
<p class="item-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</section>
</section>
<!-- End Section Two -->
<section class="grid-x align-middle section-three">
<div class="section-three-content small-12 medium-7">
<div class="grid-x grid-container grid-padding-x align-center">
<div class="small-4 medium-4 large-5 "><h1 class="number"> 2 </h1></div>
<div class="small-8 medium-8 large-7 ">
<h2 class="sub-header-one">search engine optimization</h2>
<p class="item-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</div>
<div class="section-three-content grid-container small-12 medium-5 iphone"><img src="img/iphone-x.png"></div>
</section>
<section class="grid-x align-middle section-four">
</section>
i created a responsive rectangle and a responsive triangle with css only.
How can i align the triangle so it is always vertically centered on the right side of the box?
I´d like to do it just with css but if it is not possible i appreciate any hint for alternative options.
HTML:
<div class="container">
<div class="box green rightbox">
<div class="innerbox">Lorem ipsum....</div>
</div>
<div class="mother-triangle">
<div class="triangle-right green"></div>
</div>
</div>
CSS:
.container {
max-width: 1200px;
margin-right: auto;
margin-left: auto;
z-index: 1;
position: relative;
}
.box {
height: auto!important;
min-height: 300px;
}
.box.green {
background-color: rgba(51, 223, 9, 0.75)!important;
}
.innerbox {
padding: 12px;
}
.triangle-right {
width: 0;
height: 0;
padding-top: 10%;
padding-bottom: 10%;
padding-left: 10%;
overflow: hidden;
position: relative;
margin-top: auto;
margin-bottom: auto;
display: inline-block;
vertical-align: middle;
}
.triangle-right:after {
content: "";
display: block;
width: 0;
height: 0;
margin-top: -500px;
margin-left: -500px;
border-top: 500px solid transparent;
border-bottom: 500px solid transparent;
border-left: 500px solid rgba(51, 223, 9, 0.75);
}
.rightbox {
width: 90%;
float: left;
}
JSFiddel demo:
You can use absolute positioning to do that.
Just change position: relative to position: absolute in .triangle-right.
Add top: 50% to move the triangle to the vertical middle.
Updated fiddle
.container {
max-width: 1200px;
margin-right: auto;
margin-left: auto;
z-index: 1;
position: relative;
}
.box {
height: auto!important;
min-height: 300px;
}
.box.green {
background-color: rgba(51, 223, 9, 0.75)!important;
}
.innerbox {
padding: 12px;
}
.triangle-right {
width: 0;
height: 0;
padding-top: 10%;
padding-bottom: 10%;
padding-left: 10%;
overflow: hidden;
position: absolute;
margin-top: auto;
margin-bottom: auto;
display: inline-block;
vertical-align: middle;
top: 50%;
}
.triangle-right:after {
position: absolute;
content: "";
display: block;
width: 0;
height: 0;
margin-top: -500px;
margin-left: -500px;
border-top: 500px solid transparent;
border-bottom: 500px solid transparent;
border-left: 500px solid rgba(51, 223, 9, 0.75);
}
.rightbox {
width: 90%;
float: left;
}
<!-----container start---->
<div class="container">
<div class="box green rightbox">
<div class="innerbox">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>
<div class="mother-triangle">
<div class="triangle-right green"></div>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
<!-----container end ---->
I have checked several answers on this topic, but they are either not responsive or just don't work for me.
I have two columns and I would like the right one to always match the height of the left one. If there is too much content in the right column, make it scrollable. Is that possible?
I have one example for you (using table layout):
HTML:
<div class="row no-gutter">
<div class="row-same-height">
<div class="col-xs-6 col-xs-height">
<div class="content-left">
<img src="http://www.gettyimages.in/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg" class="img-responsive">
</div>
</div>
<div class="col-xs-6 col-xs-height col-top">
<div class="content-right">
<div class="content-box">
<h2>Responsive two sections (equal height)</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
</div>
</div>
CSS:
.no-gutter.row {
margin-left: 0;
margin-right: 0;
}
.no-gutter > [class*="col-"],
.no-gutter .row-same-height > [class*="col-"] {
padding-right: 0;
padding-left: 0;
}
#media (min-width: 992px) {
.no-gutter-desktop.row {
margin-left: 0;
margin-right: 0;
}
.no-gutter-desktop > [class*="col-"],
.no-gutter .row-same-height > [class*="col-"] {
padding-right: 0;
padding-left: 0;
}
}
.inside {
margin-top: 20px;
margin-bottom: 20px;
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f4f4f4), color-stop(100%, #ededed));
background: -moz-linear-gradient(top, #f4f4f4 0%, #ededed 100%);
background: -ms-linear-gradient(top, #f4f4f4 0%, #ededed 100%);
}
.inside-full-height {
height: 100%;
margin-top: 0;
margin-bottom: 0;
}
.content {
padding: 12px 3px;
}
.row-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-height {
display: table-cell;
float: none;
height: 100%;
}
.col-top {
vertical-align: top;
}
.col-middle {
vertical-align: middle;
}
.col-bottom {
vertical-align: bottom;
}
#media (min-width: 480px) {
.row-xs-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-xs-height {
display: table-cell;
float: none;
height: 100%;
}
.col-xs-top {
vertical-align: top;
}
.col-xs-middle {
vertical-align: middle;
}
.col-xs-bottom {
vertical-align: bottom;
}
}
#media (min-width: 768px) {
.row-sm-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-sm-height {
display: table-cell;
float: none;
height: 100%;
}
.col-sm-top {
vertical-align: top;
}
.col-sm-middle {
vertical-align: middle;
}
.col-sm-bottom {
vertical-align: bottom;
}
}
#media (min-width: 992px) {
.row-md-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-md-height {
display: table-cell;
float: none;
height: 100%;
}
.col-md-top {
vertical-align: top;
}
.col-md-middle {
vertical-align: middle;
}
.col-md-bottom {
vertical-align: bottom;
}
}
#media (min-width: 1200px) {
.row-lg-height {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
}
.col-lg-height {
display: table-cell;
float: none;
height: 100%;
}
.col-lg-top {
vertical-align: top;
}
.col-lg-middle {
vertical-align: middle;
}
.col-lg-bottom {
vertical-align: bottom;
}
}
[class*="col-"] {
background: #d6ec94;
}
.content-right {
overflow-y: auto;
}
JS:
var leftHeight = $('.content-left').height();
$('.right').css('max-height', leftHeight);
$(window).resize(function () {
var leftHeight = $('.content-left').height();
$('.content-right').css('max-height', leftHeight);
});
CODEPEN
I am using display:flex in order to center/vertically center the content on the page. I have set a media query so that there is a hamburger menu for mobile size. However, there appears to be a right margin on the homePage. No matter what I try, I can't get the margin to go away. Here's a jsfiddle of it. Please help!
http://jsfiddle.net/crcommons/Lxepj9ko/2/
(p.s. make sure you adjust the browser size so that it is in mobile).
$('.hamburger').on('click', function() {
$('.menu').slideToggle();
});
function setPageHeight () {
var windowHeight = $(window).height();
var headerHeight = $('header').height();
pageHeight = (windowHeight - headerHeight);
$('.homePage').css('min-height', pageHeight + 'px');
};
setPageHeight();
$(window).resize(setPageHeight);
*, *:after, *:before {
box-sizing: border-box
}
body {
font-size: 18px;
}
.container {
margin: 0 auto;
}
nav {
background-color: white;
max-width: 100%;
padding-top: .75em;
}
.mainNav {
max-width: 1024px;
margin: 0 auto;
}
.mainNav li {
width: 19%;
display: inline-block;
border-right: 1px solid black;
text-align: center;
}
.mainNav li:last-child {
border-right: none;
}
.hamburger {
display: none;
line-height: .3em;
}
.hamburger:before {
content: "≡";
}
.homePage {
background-color: #CBD5D2;
max-width: 100%;
display: flex;
}
.introduction {
max-width: 40em;
margin: auto;
}
.logo {
text-align: center;
}
.tagline {
font-size: 3em;
text-align: center;
}
.introduction p {
text-align: justify;
}
#media screen and (max-width: 479px) {
.wrapper {
padding: 1.5em;
}
nav {
display: none;
}
.hamburger {
display: inline-block;
font-size: 3.5em;
text-decoration: none;
float: right;
}
.navigation {
float: left;
float: left;
position: absolute;
right: 0;
margin-top: 30px;
padding: 0;
background: gray;
}
.mainNav {
padding: 0;
}
.mainNav li {
display: block;
padding: .5em;
width: 100%;
}
.homePage {
padding: 1em;
}
.tagline {
font-size: 2em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="container">
<header>
<div>
</div>
<nav class="navigation menu">
<ul class="mainNav">
<li>Home</li>
<li>Page 1</li>
<li>Page 2</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
</header>
<div class="homePage">
<div class="introduction">
<h1 class="logo">Title</h1>
<h2 class="tagline">Lorem ipsum dolor sit.</h2>
<p class="introP">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officiis nam velit, voluptates dolore consequuntur ea tempore laborum mollitia, corporis impedit distinctio aperiam itaque perspiciatis repellat neque facilis esse molestiae maiores eum, incidunt eius quaerat! Dicta illo ut, incidunt ratione magni cum unde architecto obcaecati illum harum tempora veniam placeat voluptatem.</p>
</div>
</div>
</body>
One option to solve this would be within the .hamburger class media query setting position: absolute; right: 0px;
This is happening because .hamburger is floating right, and there is nothing to clear the float. .homepage has a max-width: 100% but the width is not set. Since the homepage isn't 100%, it will float around the hamburger.
Clear the float:
header::after {
content: '';
display: block;
clear: both;
}
Set homepage width to 100%:
.homepage {
background-color: #CBD5D2;
max-width: 100%;
width: 100%;
display: flex;
}