Why does background flicker on hover - css

I have the HTML and CSS below. When I hover the image it's opacity goes to zero and a background colour appears while the text goes from display:none to block. But why is there flickering when hovering the text? I have tried setting backface-visibility:hidden on all elements but it does not remove the flicker.
It happens in current Firefox & Chrome and IE11.
Here is codepen demo of the problem
<div class="project-card">
<img src="http://s13.postimg.org/tiwekrks7/dummy_small_1.jpg" height="250" width="380">
<div class="project-caption">
<div class="pc-name">Absolut Vodka</div>
<div class="pc-type">Bottle</div>
<div class="pc-task">Fancy text</div>
</div>
</div>
.project-card {
position: relative;
display: inline-block;
text-align: center;
max-width: 32%;
background-color: #0a3837;
}
.project-card p,
.project-card a,
.project-card img {
margin: 0;
}
.project-card a {
max-width: 100%;
line-height: 0;
}
.project-card a:hover {
opacity: 0.1;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.project-card a:hover + .project-caption {
display: block;
}
.project-caption {
display: none;
color: white;
font-size: 0.9rem;
padding: 0 3rem;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.pc-name {
text-transform: uppercase;
padding-bottom: 5px;
margin-bottom: 5px;
border-bottom: 2px solid white;
}
.pc-type,
.pc-task {
font-style: italic;
}

Here a solution based on what Zeta said :
HTML
<div class="project-card">
<img src="http://s13.postimg.org/tiwekrks7/dummy_small_1.jpg" height="250" width="380">
<div class="project-caption">
<div class="pc-name">Absolut Vodka</div>
<div class="pc-type">Bottle</div>
<div class="pc-task">Fancy text</div>
</div>
</div>
CSS
.project-card {
position: relative;
display: inline-block;
text-align: center;
max-width: 32%;
background-color: #0a3837;
}
.project-card p,
.project-card a,
.project-card img {
margin: 0;
}
.project-card a {
max-width: 100%;
line-height: 0;
}
.project-card:hover > a{
opacity: 0.1;
}
.project-card:hover > a + .project-caption {
display: block;
}
.project-caption {
display: none;
color: white;
font-size: 0.9rem;
padding: 0 3rem;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.pc-name {
text-transform: uppercase;
padding-bottom: 5px;
margin-bottom: 5px;
border-bottom: 2px solid white;
}
.pc-type,
.pc-task {
font-style: italic;
}
And the fiddle : https://jsfiddle.net/rf09bsse/

Related

margin auto isn't centering flex item [duplicate]

This question already has an answer here:
Proper use of flex properties when nesting flex containers
(1 answer)
Closed 3 years ago.
I'm trying to center the text area in my contact section at a max-width of 1400px; at this width I change the textarea's width from 100% to 90%. The contact section lies at the bottom of the page in the footer. The text area is a flex-item and was being centered with align-items: center but when I change the width to 90% it scoots over to the left? I tried margin left/right: auto; What's going on?
https://jsfiddle.net/yat5ncmk/9/
p.s the media query is at the bottom of the CSS
html,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.b1,
.b2,
.b3 {
width: 70px;
height: 8.5px;
border-radius: 5px;
background-color: #fff;
margin-bottom: 10px;
transition: all .15s ease;
}
.b1 {
background-color: #56ff47;
}
.b3 {
background-color: #ff4c4c;
}
a:hover {
color: #007001;
}
.info-wrap {
flex-basis: 60%;
}
.info {
font-family: 'Cedarville Cursive';
color: white;
font-weight: bold;
font-size: 4.5rem;
text-align: center;
margin-top: 60px;
}
.arrow-right {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 60px solid green;
position: relative;
top: -10px;
}
.arrow-left {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-right: 60px solid limegreen;
position: relative;
top: 20px;
}
.arrow-top {
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 60px solid #20a04b;
position: relative;
top: -100px;
left: 60px;
}
.top-middle {
position: relative;
top: -110px;
}
.bottom-middle .arrow-left {
top: -40px;
}
.bottom-middle .move {
top: -70px;
}
.bottom {
position: relative;
top: -48px;
}
.bottom .arrow-left {
top: -40px;
}
/*---------------FOOTER---------------*/
.contact-section-background {
background-color: #666;
height: 300px;
clip-path: polygon(0% 0%, 10% 30%, 90% 30%, 100% 0%, 100% 100%, 0% 100%);
margin-top: -100px;
}
.contact-section {
display: flex;
background-color: #595959;
margin-top: -225px;
position: relative;
padding-bottom: 18px;
z-index: 1;
}
.contact,
.location {
flex-basis: 50%;
display: flex;
flex-direction: column;
align-items: center;
}
.contact h1,
.location h1 {
margin: 0;
font-family: 'Cedarville Cursive';
color: white;
font-size: 7rem;
}
.hex {
-webkit-clip-path: polygon(25% 60%, 75% 60%, 100% 100%, 0% 100%);
background-color: #17a832;
transform: rotate(180deg);
width: 300px;
height: 150px;
margin: 0 auto;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
z-index: 2;
}
.rhombus {
-webkit-clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
background-color: #17a832;
width: 80px;
height: 80px;
position: absolute;
margin: 0 auto;
top: 60px;
right: 0;
left: 0;
bottom: 0;
z-index: 2;
}
.back-to-top {
color: #595959;
font-size: 2.5rem;
left: -45px;
position: relative;
transform: rotate(180deg);
top: 110px;
font-family: 'Josefin Sans';
}
.btp-arrow {
color: #595959;
font-size: 3rem;
position: absolute;
left: 50%;
margin-left: -24px;
bottom: 35px;
transition: all .2s ease;
}
.btp-arrow:hover {
color: #ddae1a;
cursor: pointer;
transform: scale(1.1);
}
.contact p {
font-family: 'Josefin Sans';
font-size: 2rem;
margin-top: 0;
margin-bottom: 10px;
color: white;
}
.textarea {
position: relative;
min-width: 500px;
}
.contact textarea {
resize: none;
width: 100%;
color: #595959;
margin: 10px;
min-height: 150px;
font-family: 'Josefin Sans';
font-size: 1.5rem;
padding: 5px;
outline: none;
border: none;
background: #474646;
border-radius: 4px;
}
.contact button {
font-size: 1.5rem;
font-family: 'Josefin Sans';
background: darkgrey;
color: #595959;
padding: 4px;
padding-right: 6px;
padding-left: 6px;
border: none;
border-radius: 4px;
cursor: pointer;
position: absolute;
bottom: 10px;
right: -20px;
transition: all .4s ease;
}
.contact button:hover {
color: #ddae1a;
}
.contact-line {
margin-top: 170px;
margin-bottom: 30px;
width: 5px;
border-radius: 3px;
height: 350px;
background: #ddae1a;
position: relative;
}
.links {
display: flex;
position: relative;
max-width: 400px;
top: -5px;
left: 7px;
}
.links i {
font-size: 2.5rem;
margin-right: 15px;
}
.links p {
font-size: 1.5rem;
margin-right: 30px;
margin-top: 8px;
}
#facebook {
color: #3b64ed;
cursor: pointer;
}
#twitter {
color: #5effeb;
cursor: pointer;
}
#yelp {
color: red;
cursor: pointer;
}
.contact-design-wrap-left {
position: absolute;
left: 0;
top: 40px;
max-height: 500px;
}
.contact-design-wrap-right {
position: absolute;
bottom: 55px;
right: 0;
transform: rotate(180deg);
}
.contact-design-wrap-left .bottom {
height: 0;
}
#align {
position: absolute;
left: 70px;
top: -15px;
}
#align2 {
position: absolute;
left: 68px;
top: -5px;
}
.grey {
border-left: 60px solid #666;
}
.light-grey {
border-right: 60px solid #848484;
}
.same {
border-left: 60px solid #848484;
}
.lighter {
border-right: 60px solid #a8a3a3;
}
.map {
position: relative;
top: 50px;
}
.map i {
position: absolute;
color: #ddae1a;
font-size: 4rem;
left: 50%;
margin-left: -24px;
}
.location .map .street-1 {
width: 300px;
position: relative;
top: 95px;
left: 170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.location .map .street-2 {
width: 300px;
position: relative;
top: 80px;
left: -170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.location .map .street-3 {
margin-top: 40px;
width: 190%;
position: relative;
top: 30px;
left: -140px;
height: 18px;
background-color: #848484;
border-radius: 8px;
}
.street-info {
color: white;
position: absolute;
font-family: 'Josefin Sans';
font-size: 1.2rem;
left: 20px;
padding-top: 3px;
}
.address {
position: absolute;
left: 50%;
top: 75px;
margin-left: -68.5px;
color: #ddae1a;
text-decoration: none;
font-family: 'Josefin Sans';
font-size: 1.2rem;
text-align: center;
}
.address:hover {
color: #ddae1a;
text-decoration: underline;
}
.copyright {
position: absolute;
bottom: 0;
left: 50%;
font-family: 'Josefin Sans';
color: #a8a3a3;
font-size: 1.8rem;
padding-bottom: 5px;
margin: 0 0 0 -253.89px;
}
/*----FOOTER----*/
#media screen and (max-width: 1700px) {
#align {
position: absolute;
left: 60px;
top: -10px;
}
#align2 {
position: absolute;
left: 58px;
top: 0px;
}
.contact-design-wrap-right {
position: absolute;
bottom: 40px;
right: 0;
transform: rotate(180deg);
}
.contact h1,
.location h1 {
font-size: 6rem;
height: 160px;
}
.contact p {
font-size: 1.5rem;
}
.contact-line {
margin-top: 160px;
margin-bottom: 30px;
width: 5px;
border-radius: 3px;
height: 270px;
background: #ddae1a;
position: relative;
}
.copyright {
position: absolute;
bottom: 0;
left: 50%;
font-family: 'Josefin Sans';
color: #a8a3a3;
font-size: 1.5rem;
padding-bottom: 5px;
margin: 0 0 0 -211.99px;
}
.contact textarea {
margin-top: 0;
}
.location .map .street-2 {
width: 280px;
position: relative;
top: 60px;
left: -170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.location .map .street-1 {
width: 280px;
position: relative;
top: 75px;
left: 170px;
height: 15px;
transform: rotate(90deg);
background-color: #848484;
border-radius: 5px;
}
.grey {
border-left: 50px solid #666;
}
.light-grey {
border-right: 50px solid #848484;
}
.same {
border-left: 50px solid #848484;
}
.lighter {
border-right: 50px solid #a8a3a3;
}
}
#media screen and (max-width: 1450px) {
.contact button {
bottom: 15px;
}
.links {
left: 10px;
}
}
#media screen and (max-width: 1400px) {
.links {
left: 40px;
}
.contact textarea {
width: 90%;
/*None of these work?
margin-left: auto;
margin-right: auto;
align-self: center;*/
}
}
<link href="https://fonts.googleapis.com/css?family=Cedarville+Cursive|Josefin+Sans|Kumar+One+Outline|Staatliches" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
<footer>
<div class="contact-section-background">
</div>
<div class="contact-section">
<div class="contact-design-wrap-left">
<div class="top">
<div class="arrow-left lighter" id="align"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
<div class="arrow-top same"></div>
</div>
<div class="top-middle">
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
</div>
<div class="bottom-middle">
<div class="arrow-right grey"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right move grey"></div>
</div>
<div class="bottom">
<div class="arrow-left light-grey"></div>
<div class="arrow-top same"></div>
<div class="arrow-left lighter" id="align2"></div>
</div>
</div>
<div class="hex">
<div class="back-to-top">Back to Top</div>
</div>
<div class="rhombus"></div>
<div class="contact">
<h1>Contact</h1>
<p class="number">(480)456-7297</p>
<p class="email">fakeEmail#fake.com</p>
<div class="textarea">
<textarea name="" id="" cols="30" rows="0" placeholder="Send us a message:)"></textarea>
<button>Send</button>
<div class="links">
<p>Leave us a review!</p>
<i class="fab fa-facebook-square" id="facebook"></i>
<i class="fab fa-yelp" id="yelp"></i>
<i class="fab fa-twitter-square" id="twitter"></i>
</div>
</div>
</div>
<div class="contact-line"></div>
<div class="location">
<h1>Location</h1>
<div class="map">
<i class="fas fa-map-marker-alt"></i>
6140 E Main St.
<div class="street-1">
<p class="street-info">63rd St.</p>
</div>
<div class="street-2">
<p class="street-info">N Recker Rd.</p>
</div>
<div class="street-3">
<p class="street-info">US 60 E.</p>
</div>
</div>
</div>
<div class="contact-design-wrap-right">
<div class="top">
<div class="arrow-left lighter" id="align"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
<div class="arrow-top same"></div>
</div>
<div class="top-middle">
<div class="arrow-left light-grey"></div>
<div class="arrow-right grey"></div>
</div>
<div class="bottom-middle">
<div class="arrow-right grey"></div>
<div class="arrow-left light-grey"></div>
<div class="arrow-right move grey"></div>
</div>
<div class="bottom">
<div class="arrow-left light-grey"></div>
<div class="arrow-top same"></div>
<div class="arrow-left lighter" id="align2"></div>
</div>
</div>
<p class="copyright">© 2019 El Metate | All Rights Reserved</p>
</div>
</footer>
The easiest solution is to give the textarea display: block so that it honors left/right margins. You can update the css inside your final media query like this:
.contact textarea {
width: 90%;
margin-left: auto;
margin-right: auto;
display: block;
}
But the min-width: 500px on the div surrounding the textarea is also causing some alignment issues. You may want to try adjusting that at smaller screen sizes as well.

Dropdown menu vanishing when hovering over background text

I can't utilize the main dropdown menu on the site I'm developing because if you move too slowly or if you mouse over text that is in the background in the child element behind it, it will vanish.
I've tried adding !important tags. I've tried looking for any gaps between elements. I've tried adjusting the z axis priority values.
.dropdown {
position: fixed;
top: 1vmin;
left: 1vmin;
width: 10vmin;
height: 10vmin;
display: inline-block;
}
.dropdown:hover .dropdown-content {display:block !important;}
.dropbtn {
background color: black;
color: black;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 99999;
}
.dropdown-content a {
color: black;
padding: 10px 10px;
text-decoration: none;
display: block !important;
}
.dropdown-content a:hover {background-color: red;}
.header {
position: fixed;
top: 1vmin;
width: calc(100vw - 14vmin);
height: 10vmin;
transform: translate(11vmin, 0vmin);
text-align: center;
padding: 0vmin;
vertical-align: middle;
dislpay: table-cell;
}
.header a {
float: left;
font-size: 4vmin;
color: white;
text-align: center;
vertical-align: middle;
padding: 1vmin 1vmin;
text-decoration: none;
}
table {
table-layout: auto;
width: 100%;
border: 1vmin solid black;
}
td {
border: 1px solid black;
overflow: hidden;
text-overflow: ellipsis;
}
td a:hover {background-color: red;}
.navbar {
width: 10vmin;
height: 10vmin;
position: relative:
border: 0.5vmin solid #49b293;
cursor: pointer;
transition: all 0.3s ease;
}
.navbar div {
height: 0.8vmin;
width: 6vmin;
background-color: #fff;
position: absolute;
transition: all 0.5s ease;
}
.navbar .first {
top: 2.5vmin;
left: 2vmin;
}
.navbar .second {
top: 4.5vmin;
left: 2vmin;
}
.navbar .third {
top: 6.5vmin;
left: 2vmin;
}
.navbar:hover .first {
width: 4vmin;
transform: translate(0vmin, 4.75vmin) rotate(50deg);
transition: all 0.5s;
}
.navbar:hover .second {
opacity: 0;
transition: all 0.5s;
}
.navbar:hover .third {
width: 4vmin;
transform: translate(2.25vmin, 0.5vmin) rotate(-50deg);
transition: all 0.5s;
}
.navbar:hover {
border-radius:5vmin;
transition: all 0.3s ease;
}
.mainbody {
position: relative;
width: 100%;
top: 13vmin;
z-index:1;
}
</style>
<div class="dropdown" style="background-color:black;">
<button class="dropbtn" style="background-color:black;">
<div class="navbar">
<div class="first"></div>
<div class="second"></div>
<div class="third"></div>
</div>
</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
<div class="header" style="background-color:black;">
<table style="background-color:black;">
<tr>
<td>Home</td>
<td>IT</td>
<td>Science</td>
<td>Tech</td>
<td>News</td>
<td>Top</td>
</tr>
</table>
</div>
<div class="mainbody">
<h1>RoyHQ</h1>
</div>
</body>
</html>
I'd like for the drop menu to be relatively resilient to vanishing. It's not, it's almost unusable.
Click menu now!
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
.dropdownzzz {
position: fixed;
top: 1vmin;
left: 1vmin;
width: 10vmin;
height: 10vmin;
display: inline-block;
}
.dropbtn {
background color: black;
color: black;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 99999;
}
.dropdown-content a {
color: black;
padding: 10px 10px;
text-decoration: none;
display: block !important;
}
.dropdown-content a:hover {background-color: red;}
.header {
position: fixed;
top: 1vmin;
width: calc(100vw - 14vmin);
height: 10vmin;
transform: translate(11vmin, 0vmin);
text-align: center;
padding: 0vmin;
vertical-align: middle;
dislpay: table-cell;
}
.header a {
float: left;
font-size: 4vmin;
color: white;
text-align: center;
vertical-align: middle;
padding: 1vmin 1vmin;
text-decoration: none;
}
table {
table-layout: auto;
width: 100%;
border: 1vmin solid black;
}
td {
border: 1px solid black;
overflow: hidden;
text-overflow: ellipsis;
}
td a:hover {background-color: red;}
.navbar {
width: 10vmin;
height: 10vmin;
position: relative:
border: 0.5vmin solid #49b293;
cursor: pointer;
transition: all 0.3s ease;
}
.navbar div {
height: 0.8vmin;
width: 6vmin;
background-color: #fff;
position: absolute;
transition: all 0.5s ease;
}
.navbar .first {
top: 2.5vmin;
left: 2vmin;
}
.navbar .second {
top: 4.5vmin;
left: 2vmin;
}
.navbar .third {
top: 6.5vmin;
left: 2vmin;
}
.navbar.active .first {
width: 4vmin;
transform: translate(0vmin, 4.75vmin) rotate(50deg);
transition: all 0.5s;
}
.navbar.active .second {
opacity: 0;
transition: all 0.5s;
}
.navbar.active .third {
width: 4vmin;
transform: translate(2.25vmin, 0.5vmin) rotate(-50deg);
transition: all 0.5s;
}
.navbar.active {
border-radius:5vmin;
transition: all 0.3s ease;
}
.mainbody {
position: relative;
width: 100%;
top: 13vmin;
z-index:1;
}
.dropdown-content.active {
display: block;
}
</style>
<div class="dropdownzzz" style="background-color:black;">
<button class="dropbtn" style="background-color:black;" id="menu">
<div class="navbar" id="iconmenu">
<div class="first"></div>
<div class="second"></div>
<div class="third"></div>
</div>
</button>
<div class="dropdown-content" id="there">
Link 1
Link 2
Link 3
</div>
</div>
<div class="header" style="background-color:black;">
<table style="background-color:black;">
<tr>
<td>Home</td>
<td>IT</td>
<td>Science</td>
<td>Tech</td>
<td>News</td>
<td>Top</td>
</tr>
</table>
</div>
<div class="mainbody">
<h1>RoyHQ</h1>
</div>
<script>
$('#menu').on('click', function () {
$('#there').toggleClass('active');
$('#iconmenu').toggleClass('active');
});
</script>

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>

When I hover over a div a new div appears ontop of the div causing the overlap to flicker when I move the mouse

Here is a link to my problem http://jsfiddle.net/xb3qkwpp/3/a
When you hover over the green area it starts to flicker when I move the mouse. I am thinking it is z-index but I have set the z-index for the class and ids and it didnt work or maybe I am doing it incorrectly.
html:
<div id="first_area_max" class="first_area">
<div class="first_area_wrapper">
<h2>
FIRST
</h2>
<h1>
foo
</h1>
<p class="tk-proxima-nova">
“I started out in concrete whenI was 18 years old and havebeen at this business for almost20 years. Our team isprofessional, knowledgeable,and will go full throttle everyday for our clients.”
</p>
</div>
</div>
<div id="second_area_max" class="second_area">
<div class="second_area_wrapper">
<h2>
SECOND
</h2>
<h1>
foo
</h1>
<p class="tk-proxima-nova">
“I started out in concrete whenI was 18 years old and havebeen at this business for almost20 years. Our team isprofessional, knowledgeable,and will go full throttle everyday for our clients.”
</p>
</div>
</div>
<div id="third_area_max" class="third_area">
<div class="third_area_wrapper">
<h2>
THIRD
</h2>
<h1>
foo
</h1>
<p class="tk-proxima-nova">
“I started out in concrete whenI was 18 years old and havebeen at this business for almost20 years. Our team isprofessional, knowledgeable,and will go full throttle everyday for our clients.”
</p>
</div>
css:
html, body {
margin: 0 auto;
background-color: black; }
h1, h2, h3 {
font-weight: normal; }
a {
text-decoration: none;
color: inherit; }
ul {
list-style-type: none;
padding: 0; }
.no-padding {
padding: 0; }
.no-margin {
margin: 0; }
.clear {
clear: both; }
.first_boss {
background: blue;
opacity: 0.7;
}
.second_boss {
background: red;
opacity: 0.7;
}
.third_boss {
background: green;
opacity: 0.7;
}
.first_page, .second_page, .third_page, .fifth_page {
background-size: cover;
background-repeat: no-repeat;
height: 800px;
max-width: 1300px; }
.first_page, .second_page, .third_page, .fifth_page {
min-width: 1000px;
background-position: center center;
margin: 0 auto; }
.fifth_page {
background-image: image-url("fifth_page.jpg");
z-index: -1;
z-index: -1; }
.fifth_page h1 {
margin-top: 0;
font-size: 40px; }
.fifth_page h1, .fifth_page h2 {
font-family: 'mohaveregular'; }
.fifth_page p {
width: 230px;
line-height: 2em;
float: right; }
.first_area, .second_area, .third_area {
color: white;
padding: 50px;
width: 500px;
height: 700px;
text-align: right;
position: relative;
top: 0px;
float: right;
background-image: image-url("owner_bg.png"); }
.first_area p, .second_area p, .third_area p {
width: 230px;
line-height: 2em;
float: right; }
#first_area_max, #second_area_max, #third_area_max {
margin-right: -850px;
z-index: 1; }
#first_mouse:hover ~ #first_area_max, #second_mouse:hover ~ #second_area_max, #third_mouse:hover ~ #third_area_max {
right: 1000px;
width: 1px;
z-index: 1;
display: block;
overflow: visible; }
.first_boss, .second_boss, .third_boss {
float: left;
height: 800px;
width: 33%;
z-index: -2; }
.first_area_wrapper, .second_area_wrapper, .third_area_wrapper {
margin-right: 70px; }
#third_area_max {
z-index: 1000; }
.text-area {
padding: 20px;
background-repeat: no-repeat;
color: white;
line-height: 1.4em;
text-transform: uppercase; }
.clear {
clear: both; }
You need to hover on the div you put on top of it as well. Because of the appearing div you lose focus on the first one, causing your hover state to switch rapidly.
.div1 {
display: block;
position: absolute;
width: 200px;
height: 200px;
background: red;
}
.div2 {
display: none;
position: absolute;
width: 200px;
height: 200px;
background: blue;
}
.div1:hover ~ .div2,
.div2:hover {
display: block;
}
<div class="div1"></div>
<div class="div2"></div>

Resources