Why the burger menu does not pop out? - css

I tried building a burger-menu that will pop out some items when clicked. I managed to create and style everything but when I click it the menu does not come out. I do not understand why, what suppose to make this happen is clicking on the check-box and it expanding the max-height of the .menu class to a specific height. I am trying to achieve this with pure css.
Here is the relevant code:
The react component I am trying to style:
...
const TopBar = () => {
...
return (
<header className="header">
<input className="menu-btn" type="checkbox" id="menu-btn" />
<label className="menu-icon" htmlFor="menu-btn"><span className="nav-icon"></span></label>
<div className="logo">Sort Visualizer</div>
<section className="menu">
<div className="algorithm-select">
<select name="Sorting Algorithm"
id="algorithm"
onChange={(e) => handleAlgorithmSelect(e)}
value={data.sortingAlgorithm}>
{sortManager.getAllAlgorithms().map((value) =>
<option value={value}
key={shortid.generate()}
>{value}</option>)}
</select>
</div>
<div className="array-size">
<div className="slider-container">
5
<input type="range"
min="5"
max="100"
value={data.length}
onChange={(e) => handleLength(e)}
className="slider"
id="myRange"
/>
100
</div>
</div>
<div>
<button className="randomize-btn" onClick={() => generateArray()}>Randomize</button>
</div>
</section>
</header>
);
}
export default TopBar;
Here is the whole stylesheet:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 62.5%;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/* TopBar */
.header {
background-color: #222;
color: #fff;
box-shadow: 1px 3px 10px 0 rgba(0, 0, 0, .4);
position: fixed;
width: 100%;
height: 8%;
z-index: 3;
}
.header .menu {
clear: both;
max-height: 0;
transition: max-height .2s ease-out;
overflow: hidden;
}
.header .menu div {
display: block;
padding: 20px;
border-right: 1px solid #ccc;
}
.header .logo {
float: left;
display: block;
font-size: 3rem;
padding: 5px 20px;
}
.header .menu-btn {
position: absolute;
top: 0;
right: 0;
z-index: 2;
cursor: pointer;
width: 45px;
height: 45px;
opacity: 0;
}
.header .menu-icon {
position: absolute;
top: 0;
right: 0;
z-index: 1;
width: 40px;
height: 40px;
margin: 6px 5px;
display: flex;
align-items: center;
justify-content: center;
}
.header .menu-icon .nav-icon {
position: relative;
width: 75%;
height: 2px;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.4s ease;
}
.header .menu-icon .nav-icon:before,
.header .menu-icon .nav-icon:after {
content: '';
position: absolute;
z-index: 1;
top: -9px;
width: 100%;
height: 2px;
background: inherit;
}
.header .menu-icon .nav-icon:after {
top: 9px;
}
.header .menu-btn:checked + .menu-icon .nav-icon {
transform: rotate(135deg);
}
.header .menu-btn:checked + .menu-icon .nav-icon:before,
.header .menu-btn:checked + .menu-icon .nav-icon:after {
top: 0;
transform: rotate(90deg);
}
.header .menu-btn:checked ~ .menu {
max-height: 240px;
}
I tried a few things but it wasn't successful. What am I missing?

Related

How to make Search bar slide from right to left

This search bar now expands from left to right while hover or click. How to modify it, so it expands from right to left. CSS Only, no JS. I want to place this on the right side of the page.
Please help in modifing this code so it expands from the right to left.
Now, when the bar is sticky to the right side, it shakes a bit while expanding. Changing expand direction will remove shake effect.
.search-sticky {
position: sticky;
top: 30px;
left: 100%;
z-index: 55;
border-radius: 50px;
background-color: red;
padding: 2.5rem;
}
.search-icon {
position: relative;
width: 24px;
height: 24px;
flex-shrink: 0;
top: 3px
}
.search-input {
outline: none;
border: none;
background: none;
width: 0;
padding: 0;
color: white;
float: left;
transition: .3s;
line-height: 1.5;
font-size: 6rem;
position: relative;
left: 1rem;
}
.search-btn {
float: right;
width: 40px;
height: 40px;
border-radius: 50px;
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
transition: .3s;
}
.search-input:focus,
.search-input:not(:placeholder-shown) {
width: 200px;
}
.search-box:hover>.search-input {
width: 200px;
}
.search-box:hover>.search-btn,
.search-input:focus+.search-btn,
.search-input:not(:placeholder-shown)+.search-btn {
background: grey;
}
.search-sticky:hover,
.search-sticky:focus-within {
background-color: grey;
}
.search-sticky button {
padding: 0;
background: none;
border: none;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
}
<div class="search-sticky">
<form class="search-box">
<input type="text" name="q" id="search-query" class="search-input" placeholder="Search ....">
<a class="search-btn" href="#">
<button type="submit" class="search-button"><img class="search-icon" alt="Search" src="/icons/search.svg" /></button>
</a>
</form>
</div>
Updated
I hope this helps
.search-sticky {
position: sticky;
top: 30px;
left: 100%;
z-index: 55;
border-radius: 50px;
background-color: whitesmoke;
padding: 0.5rem 2.5rem;
}
.search-box{
display: flex;
justify-content: space-between;
align-items: center;
}
.search-icon {
position: relative;
width: 40px;
height: 40px;
margin-left: auto;
}
.search-input {
outline: none;
border: none;
background: none;
width: 0;
padding: 0;
color: white;
transition: .3s;
line-height: 1.5;
font-size: 4rem;
position: relative;
display: inline-block;
}
.search-btn {
width: 40px;
height: 40px;
border-radius: var(--br-md);
display: inline-block;
justify-content: center;
align-items: center;
text-decoration: none;
transition: .3s;
}
.search-input:focus,
.search-input:not(:placeholder-shown) {
width: calc(100% - 60px);
}
.search-box:hover>.search-input {
width: calc(100% - 60px);
}
/*.search-box:hover>.search-btn,
.search-input:focus+.search-btn,
.search-input:not(:placeholder-shown)+.search-btn {
background: grey;
}
// not needed */
.search-sticky:hover,
.search-sticky:focus-within {
background-color: lightgray;
}
.search-sticky button {
padding: 0;
background: none;
border: none;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
cursor: pointer;
}
<div class="search-sticky">
<form class="search-box">
<input type="text" name="q" id="search-query" class="search-input" placeholder="Search ....">
<a class="search-btn" href="#">
<button type="submit" class="search-button"><img class="search-icon" alt="Search" src="https://img.icons8.com/ios-filled/2x/search.png" /></button>
</a>
</form>
</div>

Getting SVG plus symbol to appear to the right of tab, not the right of the containing div

So I've got a problem where I've got two tabs (https://codepen.io/databell/pen/LYjxvyx) where the first tab opens up content and the second opens up a modal.
Now to be clear, those functions work. That's not the issue. So for those purposes, I deleted those out of my example. Focusing on CSS here.
My problem is I want plus + symbols to appear to the right side of each tab (really a div) and instead one tab has the symbol to the far right of the container, even though the tab is set to width 100%. So I'm stumped as to what the problem is.
This is meant to go into a Shopify store using the Dawn theme, so I'm using their elements here to create this interface.
Here's the code.
<div id="info-additions" class="product__accordion accordion info-additions-content" >
<details>
<summary>
<div class="summary__title info-additions-tab g-flex">
<h2 class="h4 accordion__title t-body benefits">
Tab One
<span></span>
</h2>
</div>
<div class="summary__title info-additions-tab g-flex">
<modal-opener class="product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-ingr">
<button id="ProductPopup-ingr" class="summary__title t-body ingredients" type="button" aria-haspopup="dialog" data-additions-tab="ingredients">
<h2 class="h4 accordion__title">
Tab Two
<span></span>
</h2>
</button>
</modal-opener>
</div>
</summary>
<div class="accordion__content rte">
<p>Content</p>
</div>
</details>
</div>
CSS:
body {
font-size: 1.6rem;
}
*, ::before, ::after {
box-sizing: inherit;
}
.h0, .h1, .h2, .h3, .h4, .h5, h1, h2, h3, h4, h5 {
letter-spacing: .06rem;
line-height: 1.3;
}
.h4, h4 {
font-size: 1.6rem;
}
.grid {
list-style: none;
}
.g-flex {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
}
.accordion summary {
cursor: pointer;
display: flex;
position: relative;
list-style: none;
line-height: 1;
padding: 1.5rem 0;
}
.accordion__title {
display: inline-block;
max-width: calc(100% - 6rem);
min-height: 1.6rem;
margin: 0;
word-break: break-word;
}
details > * {
box-sizing: border-box;
}
.accordion__title {
word-break: break-word;
}
.accordion .summary__title {
display: flex;
flex: 1;
}
#info-additions {
clear: both;
height: auto;
margin: 15px 0 0;
border-top: 2px solid;
border-bottom: 2px solid;
width: 100%;
}
.info-additions-content {
position: relative;
height: 0;
transition: .6s var(--a-cubic-1);
}
.info-additions-tab {
justify-content: space-between;
}
.info-additions-tab span {
display: block;
position: absolute;
width: 18px;
height: 18px;
top: 13px;
right: 2rem;
}
.info-additions-tab button {
position: relative;
padding: 16px 0!important;
line-height: 1;
font-weight: 500;
text-align: left;
}
.info-additions-tab button.benefits {
width: 50%;
}
.info-additions-tab .product-popup-modal__opener {
width: 100% !important;
}
.info-additions-tab button.ingredients {
width: 100%;
}
.info-additions-tab span {
display: block;
position: absolute;
width: 18px;
height: 18px;
top: 13px;
right: 2rem;
}
.info-additions-tab span:before,
.info-additions-tab span:after {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%) rotate(90deg);
transform: translate(-50%, -50%) rotate(90deg);
width: 2px;
height: 18px;
background-color: black;
transition: 0.3s;
}
.info-additions-tab button:not(.active) span:after {
-webkit-transform: translate(-50%, -50%) rotate(180deg);
transform: translate(-50%, -50%) rotate(180deg);
}
.info-additions-content {
position: relative;
height: 0;
transition: 0.6s var(--a-cubic-1);
}
.info-additions-content [data-additions-content] {
position: absolute;
width: 100%;
top: 0;
left: 0;
padding: 5px 0 20px;
opacity: 0;
pointer-events: none;
transition: 0.3s 0s;
}
.info-additions-content [data-additions-content].active {
opacity: 1;
pointer-events: auto;
transition-delay: 0.4s;
}
#info-additions button {
padding: 0;
background: transparent;
color: inherit;
cursor: pointer;
border: 0;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
transition: 0.2s;
}
if you want an absolute element like + to stay in the parent element you have to set the position of the parent to "relative".
you have two problems. summary__title doesn't have a position so + doesn't stay in it .
for the second tab, your modal button has a relative position that makes the + stay inside of it instead of the summary__title.
.accordion .summary__title {
...
position: relative; // add position
}
#info-additions button {
...
position: unset; // unset the position of the button
}

Z-index not rendering properly in Safari - works in all other browsers

I have a nav menu that slides into view from the right side of the screen once the hamburger icon is clicked. It works correctly in Chrome and Firefox - basically when triggered it takes up 50vw and fills the screen vertically. However in Safari it seems as if the z-index is not behaving correctly because the menu appears to be buried underneath the other elements of the page and ultimately not visible at all.
I've tried adjusting the z-index of a variety of elements to see if that was the simple fix and it has proven to be something more complicated. I have read a few forums that suggested including "-webkit-transform: translate3d(0, 0, 0);" but unfortunately that doesnt seem to work either. If you inspect the sidebarMenu element in Safari you can see that it is in the correct position, it is just not rendering correctly.
Below is a link to a codepen - I am missing some styles on this so the positioning isnt quite right but it effectively shows the general functionality that I am looking for. When opening this link in Safari you can see that the sidebarMenu does not appear to be rendering at all.
https://codepen.io/rmann20/pen/EzbeaV
sample code:
<div class="header">
<hr class="nav-rule">
<div class="nav-container">
<div class="nav-logo-container">
<img class="nav-logo" src="images/nav_logo.png">
<input type="checkbox" class="openSidebarMenu" id="openSidebarMenu">
<label for="openSidebarMenu" class="sidebarIconToggle">
<div class="spinner diagonal part-1"></div>
<div class="spinner horizontal"></div>
<div class="spinner diagonal part-2"></div>
</label>
<div id="sidebarMenu">
<ul class="sidebarMenuInner">
<li>Rooms & Suites</li>
<li>Packages</li>
<li>Eat & Drink</li>
<li>Meetings & Events</li>
<li>Weddings</li>
<li>Experiences</li>
<li>Neighborhood</li>
</ul>
<ul class="sidebarMenuInnerSecondary">
<li>ABOUT</li>
<li>HISTORY</li>
<li>GALLERY</li>
<li>PRESS</li>
<li>CONTACT</li>
<li>CAREERS</li>
</ul>
</div>
</div>
<img class="nav-tagline" src="images/nav_tagline.png">
<a class="nav-reservation-button" href="" target="_blank">RESERVE NOW</a>
</div>
<hr class="nav-rule">
</div>
.header {
display: flex!important;
flex-wrap: wrap;
margin: 0;
padding: 10px 0 10px 0;
width: 100%;
max-width: 100%;
box-shadow: none;
background-color: #f5f4f0;
position: fixed;
height: 110px!important;
overflow: hidden;
z-index: 10;
justify-content: space-between!important;
}
.nav-container {
display: flex;
height: 79px;
width: 100%;
align-items: center;
justify-content: space-between;
}
.main {
margin: 0 auto;
display: block;
height: 100%;
margin-top: 60px;
}
.mainInner{
display: table;
height: 100%;
width: 100%;
text-align: center;
}
.mainInner div{
display:table-cell;
vertical-align: middle;
font-size: 3em;
font-weight: bold;
letter-spacing: 1.25px;
}
#sidebarMenu {
min-height: 100%;
position: fixed;
right: 0;
width: 50vw;
margin-top: 42px;
transform: translateX(50vw);
transition: transform 250ms ease-in-out;
background-color: #f5f4f0;
overflow: scroll;
padding: 60px 60px 60px 60px;
z-index: 10000!important;
}
.sidebarMenuInner{
margin:8px;
padding:0;
border-top: 1px solid rgba(255, 255, 255, 0.10);
list-style: none;
}
.sidebarMenuInner li a{
color: #3d3936;
font-family: 'QuincyCF-ExtraBold', Helvetica, Arial, Sans-Serif;
font-weight: normal;
font-style: normal;
cursor: pointer;
text-decoration: none;
font-size: 3.2em;
}
.sidebarMenuInnerSecondary {
margin-top: 60px;
list-style: none;
}
.sidebarMenuInnerSecondary li {
margin-top: 14px;
margin-bottom: 14px;
}
input[type="checkbox"]:checked ~ #sidebarMenu {
transform: translateX(0);
}
input[type=checkbox] {
transition: all 0.3s;
box-sizing: border-box;
display: none;
}
.sidebarIconToggle {
transition: all 0.3s;
box-sizing: border-box;
cursor: pointer;
position: absolute;
z-index: 99;
height: 100%;
width: 100%;
top: 48px;
right: 40px;
height: 28px;
width: 28px;
}
.spinner {
transition: all 0.3s;
box-sizing: border-box;
position: absolute;
height: 3px;
width: 100%;
background-color: #3d3936;
}
.horizontal {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
.diagonal.part-1 {
position: relative;
transition: all 0.3s;
box-sizing: border-box;
float: left;
}
.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .horizontal {
transition: all 0.3s;
box-sizing: border-box;
opacity: 0;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-1 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(135deg);
margin-top: 8px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(-135deg);
margin-top: -9px;
}
.nav-logo-container {
width: 260px;
margin-left: 40px;
}
I dont get any errors and everything else seems to be working correctly, can't figure out why it's not showing at this point. Any help would be greatly appreciated!

CSS dropdown cropped by topnav

I've a simple page containing: a header, a topnav and a body.
The topnav would contain a link (variable width since it will be the name of the logged user) to open a dropdown menu.
Problem: The dropdown menu is "cropped" by the topnav.
I've tried the z-index solution, but no success.
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16pt;
}
.header {
background-color: #F1F1F1;
text-align: center;
padding: 20px;
font-size: 18pt;
font-weight: bold;
}
.topnav {
position: relative;
top:0;
overflow: hidden;
background-color: #333;
font-weight: bold;
z-index: 1;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
cursor:pointer
}
.topnav a:hover {
transition-delay: 70ms;
background-color: #ddd;
color: black;
}
.active {
background-color: #4CAF50;
color: white;
}
.dropdown {
position: absolute;
display: inline-block;
float: right;
overflow: hidden;
margin: 0;
z-index: 100;
}
.dropdown-content {
display: none;
position: absolute;
top: 70%;
padding-top: 0px;
color: #f2f2f2;
background-color: blue;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 200;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
/* Finestra modal */
.container {
padding: 30px;
}
span.psw {
float: right;
padding-top: 16px;
}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 30%; /* Could be more or less, depending on screen size */
}
/* Full-width input fields */
.modal input[type=text], .modal input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
/* Set a style for all buttons */
.modal button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
font-weight: bold;
}
.imgcontainer {
font-weight: bold;
text-align: center;
margin: 24px 0 12px 0;
position: relative;
}
/* The Close Button (x) */
.close {
position: absolute;
right: 9px;
top: -20px;
color: #000;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
/* Add Zoom Animation */
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}
}
#keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* Change styles for span and cancel button on extra small screens */
#media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
<link rel="stylesheet" href="css/topnav.css">
<!-- HEADER -->
<div class="header">
Sistema di Gestione
</div>
<!-- BARRA MENU -->
<div class="topnav" id="navbar">
<a class="active" href="index.php">Home</a>
Segnalazioni
<div class="dropdown"><a>Dropdown></a>
<div class="dropdown-content"><a>BANANA</a></div>
</div>
</div>
<!-- Form di Login -->
<div id="finestra" class="modal">
<div class="modal-content">
<form class="login" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="imgcontainer">
<span onclick="document.getElementById('finestra').style.display='none'" class="close" title="Chiudi finestra">×</span>
</div>
<div class="container">
<input type="text" placeholder="Username" name="username" required>
<input type="password" placeholder="Password" name="password" required>
<button type="submit" name="login" value="login">Login</button>
</div>
</form>
</div>
</div>
<!-- Script per chiudere il modal -->
<script>
// Get the modal
var modal = document.getElementById('finestra');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
Your issue with overflow:hidden given in parent divs of dropdown.
Changed below css
.topnav {
position: relative;
top: 0;
/* overflow: hidden; */ // Removed
background-color: #333;
font-weight: bold;
z-index: 1;
display: block;
width: 100%; // Added
height: 48px; // Added
}
.dropdown {
position: absolute;
display: inline-block;
float: right;
/* overflow: hidden; */ // Removed
margin: 0;
z-index: 100;
}
body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: 16pt;
}
.header {
background-color: #F1F1F1;
text-align: center;
padding: 20px;
font-size: 18pt;
font-weight: bold;
}
.topnav {
position: relative;
top:0;
/* overflow: hidden; */
background-color: #333;
font-weight: bold;
z-index: 1;
width: 100%;
height: 48px;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
cursor:pointer
}
.topnav a:hover {
transition-delay: 70ms;
background-color: #ddd;
color: black;
}
.active {
background-color: #4CAF50;
color: white;
}
.dropdown {
position: absolute;
display: inline-block;
float: right;
/*overflow: hidden;*/
margin: 0;
z-index: 100;
}
.dropdown-content {
display: none;
position: absolute;
top: 70%;
padding-top: 0px;
color: #f2f2f2;
background-color: blue;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 200;
}
.dropdown:hover .dropdown-content {
display: block;
}
#media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
#media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
/* Finestra modal */
.container {
padding: 30px;
}
span.psw {
float: right;
padding-top: 16px;
}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 30%; /* Could be more or less, depending on screen size */
}
/* Full-width input fields */
.modal input[type=text], .modal input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
/* Set a style for all buttons */
.modal button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
font-weight: bold;
}
.imgcontainer {
font-weight: bold;
text-align: center;
margin: 24px 0 12px 0;
position: relative;
}
/* The Close Button (x) */
.close {
position: absolute;
right: 9px;
top: -20px;
color: #000;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
/* Add Zoom Animation */
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
#-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}
}
#keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* Change styles for span and cancel button on extra small screens */
#media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
.cancelbtn {
width: 100%;
}
}
<link rel="stylesheet" href="css/topnav.css">
<!-- HEADER -->
<div class="header">
Sistema di Gestione
</div>
<!-- BARRA MENU -->
<div class="topnav" id="navbar">
<a class="active" href="index.php">Home</a>
Segnalazioni
<div class="dropdown"><a>Dropdown></a>
<div class="dropdown-content"><a>BANANA</a></div>
</div>
</div>
<!-- Form di Login -->
<div id="finestra" class="modal">
<div class="modal-content">
<form class="login" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="imgcontainer">
<span onclick="document.getElementById('finestra').style.display='none'" class="close" title="Chiudi finestra">×</span>
</div>
<div class="container">
<input type="text" placeholder="Username" name="username" required>
<input type="password" placeholder="Password" name="password" required>
<button type="submit" name="login" value="login">Login</button>
</div>
</form>
</div>
</div>
<!-- Script per chiudere il modal -->
<script>
// Get the modal
var modal = document.getElementById('finestra');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>

Using skew on parent causes sidenav to lose position

Sorry for the wording, i'm not sure exactly how to phrase it.
I have a header and a container which contains a sidenav and button to toggle it. I am trying to skew the header while keeping the container normal by skewing in the opposite direction. However doing this causes the sidenav to lose it's height:100% and it doesn't stick to the left.
How can i skew the background without affecting the sidenave?
Here is the fiddle and code
https://jsfiddle.net/q0ddzw4v/
HTML
<body id="body">
<header class="header">
<div class="header__container">
<div id="mySidenav" class="sidenav">
×
About
Services
Clients
Contact
</div>
<div id="main">
<h2>Sidenav Push Example</h2>
<p>Click on the element below to open the side navigation menu, and push this content to the right.</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ open</span>
</div>
</div>
</header>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
</script>
</body>
CSS
body {
font-family: sans-serif;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
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;
}
.sidenav a:hover,
.offcanvas a:focus {
color: #f1f1f1;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
#main {
padding: 16px;
}
.header {
width: 100%;
height: 100vh;
background-color: #C18D8D;
transform: skewY(-10deg);
}
.header__container {
width: 80%;
max-width: 71.25rem;
margin: auto;
display: flex;
flex-direction: column;
height: 100%;
transform: skewY(10deg);
}
Instead of skewing the .header container, add a pseduo-element and skew it:
body {
font-family: "Lato", sans-serif;
transition: margin-left 0.5s;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
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;
}
.sidenav a:hover,
.offcanvas a:focus {
color: #f1f1f1;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
#main {
transition: margin-left .5s;
padding: 16px;
}
.header {
position: relative;
width: 100%;
height: 100vh;
}
.header::before {
display: block;
position: absolute;
width: 100%;
height: 100%;
background-color: #C18D8D;
transform: skewY(-10deg);
content: '';
}
.header__container {
position: relative;
z-index: 0;
width: 80%;
max-width: 71.25rem;
margin: auto;
display: flex;
flex-direction: column;
height: 100%;
}
<header class="header">
<div class="header__container">
<div id="mySidenav" class="sidenav">
×
About
Services
Clients
Contact
</div>
<div id="main">
<h2>Sidenav Push Example</h2>
<p>Click on the element below to open the side navigation menu, and push this content to the right.</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ open</span>
</div>
</div>
</header>
<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
// document.getElementById("body").style.marginLeft = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
// document.getElementById("body").style.marginLeft = "0";
}
</script>

Resources