I don't know how to fix this hover effect - html

I'm trying to create a hover effect where words appear over the hero section when the mouse hovers over it. If you uncomment the code at the bottom of the CSS file you will see that the code works just fine. The only problem is the backround picture dispears and turns completely white. I don't know how to fix it.
Uncomment the code all the way at the bottom of the CSS to see what I'm talking about
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: "Kumbh Sans", sans-serif;
scroll-behavior: smooth;
}
.navbar {
background: #131313;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.2rem;
position: sticky;
top: 0;
z-index: 555;
}
.navbar__container {
display: flex;
justify-content: space-between;
height: 80px;
z-index: 1;
width: 100%;
max-width: 1300px;
margin: 0 auto;
padding: 0 20px;
}
#navbar__logo {
background-color: #ff8d02;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
display: flex;
align-items: center;
cursor: pointer;
text-decoration: none;
font-size: 2rem;
}
#trade {
background-color: #0045f2;
-webkit-background-clip: text;
-moz-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-text-fill-color: transparent;
display: flex;
position: relative;
font-size: 13px;
bottom: 6px;
}
.navbar__menu {
display: flex;
align-items: center;
list-style: none;
}
.navbar__item {
height: 80px;
}
.navbar__links {
color: #fff;
display: flex;
align-items: center;
justify-content: center;
width: 120px;
text-decoration: none;
height: 100%;
transition: all 0.3s ease;
}
.navbar__btn {
display: flex;
justify-content: center;
align-items: center;
padding: 0 1rem;
width: 100%;
}
.button {
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
padding: 10px 20px;
height: 100%;
width: 100%;
border: none;
outline: none;
border-radius: 4px;
background: #833ab4;
background: -webkit-linear-gradient(to right, rgb(240, 105, 2), #8c8393, #4d7fff);
background: linear-gradient(to right, rgb(240, 105, 2), #8c8393, #4d7fff);
color: #fff;
transition: all 0.3s ease;
}
.navbar__btn:after {
position: absolute;
content: '';
top: 0;
left: 0;
width: 0;
height: 100%;
border-radius: 4px;
transition: all 1s ease;
}
.navbar__links:hover {
color: #ff7802;
transition: all 0.3s ease;
}
#media screen and (max-width: 960px) {
.navbar__container {
display: flex;
justify-content: space-between;
height: 80px;
z-index: 1;
width: 100%;
max-width: 1300px;
padding: 0;
}
.navbar__menu {
display: grid;
grid-template-columns: auto;
margin: 0;
width: 100%;
position: absolute;
top: -1000px;
opacity: 1;
transition: all 0.5s ease;
z-index: -1;
}
.navbar__menu.active {
background: #131313;
top: 100%;
opacity: 1;
transition: all 0.5s ease;
z-index: 99;
height: 60vh;
font-size: 1.6rem;
}
#navbar__logo {
padding-left: 25px;
}
.navbar__toggle .bar {
width: 25px;
height: 3px;
margin: 5px auto;
transition: all 0.3s ease-in-out;
background: #fff;
}
.navbar__item {
width: 100%;
}
.navbar__links {
text-align: center;
padding: 2rem;
width: 100%;
display: table;
}
.navbar__btn {
padding-bottom: 2rem;
}
.button {
display: flex;
justify-content: center;
align-items: center;
width: 80%;
height: 80px;
margin: 0;
}
#mobile-menu {
position: absolute;
top: 20%;
right: 5%;
transform: translate(5%, 20%);
}
.navbar__toggle .bar {
display: block;
cursor: pointer;
}
#mobile-menu.is-active .bar:nth-child(2) {
opacity: 0;
}
#mobile-menu.is-active .bar:nth-child(1) {
transform: translateY(8px) rotate(45deg);
}
#mobile-menu.is-active .bar:nth-child(3) {
transform: translateY(-8px) rotate(-45deg);
}
}
/* Hero Section */
.hero {
padding: 50px 0;
background-image: url(./images/brooke-cagle-g1Kr4Ozfoac-unsplash.jpg);
background-size: cover;
overflow: hidden;
position: relative;
background-position: top;
display: flex;
flex-direction: column;
}
.hero__heading {
color: #fff;
font-size: 100px;
margin-left: 30px;
text-shadow: 2px 2px 8px #000000c4;
}
.orange {
color: rgb(255, 89, 0);
}
.main__btn {
margin: 0 auto;
margin-top: 3rem;
}
.main__btn a {
color: #fff;
text-decoration: none;
z-index: 2;
position: relative;
padding: 10px 20px;
font-size: 1.8rem;
}
.button__color {
background: -webkit-linear-gradient(to right, #1e5dff, rgb(255, 89, 0) );
background: linear-gradient(to right, #1e5dff, rgb(255, 89, 0));
}
/*
.hero_two {
position: relative;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
color: #ffffff;
opacity: 0;
transition: all 0.25s ease;
}
.hero_two > * {
transform: translateY(20px);
transition: all 0.25s ease;
}
.hero_two:hover {
opacity: 1;
}
.hero_two:hover {
transform: translateY(0);
} */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pigeon</title>
<link rel="stylesheet" href="style.css" />
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.14.0/css/all.css"
integrity="sha384-HzLeBuhoNPvSl5KYnjx0BT+WB0QEEqLprO+NBkkk5gbc67FTaL7XIGa2w1L0Xbgc"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css" integrity="sha384-SZXxX4whJ79/gErwcOYf+zWLeJdY/qpuqC4cAa9rOGUstPomtqpuNWT9wdPEn2fk" crossorigin="anonymous">
</head>
<body>
<!-- Navbar Section -->
<nav class="navbar">
<div class="navbar__container">
Pigeon<small id="trade">TRADE</small>
<div class="navbar__toggle" id="mobile-menu">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
<ul class="navbar__menu">
<li class="navbar__item">
Home
</li>
<li class="navbar__item">
About
</li>
<li class="navbar__item">
Services
</li>
<li class="navbar__btn">
Sign Up
</li>
</ul>
</div>
</nav>
<!-- Hero Section -->
<div class="hero_two hero" id="home">
<div class="hero__container">
<div class="image__overlay">
<div class="hero__content">
<h1 class="hero__heading">Get started <br>making your <span class="orange">online <br>business</span> today!</h1>
</div>
</div>
</div>
<div class="main__btn">
<button class="button button__color">Explore</button>
</div>
</div>
```

The problem is that you are overwriting the background-image property value from .hero when you add background: rgba(0, 0, 0, 0.6); for .hero_two
Use instead background-color: rgba(0, 0, 0, 0.6);
The property background is a shorthand for all background properties including background-image.
The background shorthand CSS property sets all background style properties at once, such as color, image, origin and size, or repeat method.
Read more here -> background property
See below
EDIT after comments:
You are using two classes on the SAME element. If you write some styles for hero_two it will overwrite the styles for hero. because you are selecting the same element.
If I understand correctly, you want to show an 'overlay' and make the text appear when hovering. You can use a pseudo-element for that ( :after in this case) and some tweaks in your css styling. ( Remove the hero_two classname because it's useless )
/* Hero Section */
.hero {
padding: 50px 0;
background-image: url("https://via.placeholder.com/150");
background-size: cover;
overflow: hidden;
position: relative;
background-position: top;
display: flex;
flex-direction: column;
}
.hero__heading {
color: #fff;
font-size: 100px;
margin-left: 30px;
text-shadow: 2px 2px 8px #000000c4;
}
.orange {
color: rgb(255, 89, 0);
}
.main__btn {
margin: 0 auto;
margin-top: 3rem;
}
.main__btn a {
color: #fff;
text-decoration: none;
z-index: 2;
position: relative;
padding: 10px 20px;
font-size: 1.8rem;
}
.button__color {
background: -webkit-linear-gradient(to right, #1e5dff, rgb(255, 89, 0));
background: linear-gradient(to right, #1e5dff, rgb(255, 89, 0));
}
.hero:after {
content: "";
position: absolute;
background-color: rgba(255, 255, 255, 0.6);
top: 0;
opacity: 0;
width: 100%;
height: 100%;
}
.hero * {
transform: translateY(20px);
transition: all 0.25s ease;
opacity: 0;
}
.hero:hover * {
transform: translateY(0px);
color: #ffffff;
opacity: 1;
}
.hero:hover:after {
opacity: 1;
}
<div class="hero_two hero" id="home">
<div class="hero__container">
<div class="image__overlay">
<div class="hero__content">
<h1 class="hero__heading">Get started <br>making your <span class="orange">online <br>business</span> today!</h1>
</div>
</div>
</div>
<div class="main__btn">
<button class="button button__color">Explore</button>
</div>
</div>
Next time please share only relevant code ( eg. navbar has nothing to do with this ) and take the time to make a code snippet like the one above that reproduces your problem. ( For images, please use a placeholder as we cannot use your own images 'cause we don't have them )
happy coding.

Related

Problem with creating responsive overlapping Divs

The imagine above shows the browser in a smartphone size and thus the stretched space at the right caused by the overlapped divs in blue and red that I put below.
My main aim here was to get these divs to also shrink together with the screen but when I tried using flex properties, it disoriented whenever the page was reduced from desktop size.
Also, I tried percentages but placing the divs at a position after using percentage to size proved rather abortive.
The codes for the the image are found below.
Much help would be appreciated.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Acadera Renewed</title>
    <link rel="stylesheet" href="Acadera Imp.css">
</head>
<body>
    <div class="head_section">
        <div id="top_layout">
           <center>
           <ul>
            <li><a>Home</a></li>
            <li><a>Pages</a></li>
            <li> <a>Services</a></li>
            <li><a>Gallary</a></li>
            <li><a>Blog</a></li>
            <li><a>Contact</a></li>
            <li><a>About</a></li>
       
            <li><input type="text" placeholder="Search"></input></li>
        </ul>
    </center>
        </div>
        <h1>WELCOME TO ACADERA</h1>
        <p>We bring you the best there is to offer</p>
       <center><input type="button" class= "btn" value="GET STARTED" ></input></center>
        <div class="lower_section">
           <center>
           <ul class="two">
            <li id="lower"><a href="" class="lower">Akan</a></li>
            <li id="lower"><a href="" class="lower">Uwem</a></li>
            <li id="lower"><a href="" class="lower">Itoro</a></li>
        </ul>
        </center>
        </div>
    </div>
    
   <div class="contain">
       <div class="box red"> </div>
       <div class="box blue"></div>
    </div>
</body>
</html>
CSS
*{
    padding: 0px;
    margin: 0px;
    box-sizing: border-box;
}
 body{
    background-color: white;
    overflow: auto;
    background-attachment: scroll;
    min-width: 100%;
} 
.head_section{
    position: relative;
    z-index: 1;
    height: 32rem;
    width: 100%;
    background-color: black;
}
.head_section::before{
    content: "";
    z-index: -1;
    position: absolute;
    height: 32rem;
    width: 100%;
    color: black;
    background-image: url(image/pexels-birgit-held-1046125.jpg);
    background-position: center;
    background-attachment: fixed;
    background-size: cover;
    opacity: 0.6;
}
/* 
#top_layout{
    padding:5px 0 5px 0;
    text-align: center;
    justify-content: center;
} */
ul{
    margin: auto 0px;
    padding: 0px;
    list-style: none;
    display: table;
    width: 80%;
    text-align: center;
    /* background-color: red;  */
}
.two{
    margin: auto 0px;
    padding-bottom: 40px;
    list-style: none;
    display: table;
    width: 80%;
    text-align: center;
    top: 0px;
}
li{
    display: table-cell;
    position: relative;
    padding: 5px 10px 5px 12px;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.15em;
    display: inline-block;
    position: relative;
    /* background-color: blue; */
}
#lower{
    display: table-cell;
    padding: 10px 13px 40px 15px;
    /* background-color: blue; */
    text-transform: uppercase;
    font-size: 15px;
    letter-spacing: 0.15em;
    position: relative ;
    /* padding-top: 50px; */
    position: 0;
    
   
}
a{
    padding: 5px 10px;
    color: white;
    text-decoration: none;
    top: 0px;
    /* background-color: grey; */
    margin-bottom: 20px;
}
a:hover{
    color: yellow;
    cursor: pointer;
}
a:after{
    background: none repeat scroll 0 0 transparent;
    bottom: 0;
    content: "";
    display: block;
    height: 2px;
    left: 50%;
    position: absolute;
    background: yellow;
    transition: width 0.3s ease 0s, left 0.3s ease 0s;
    width: 0px;
}
a:hover:after{
    width: 100%;
    left: 0;
}
#media screen and (max-height:300px){
    ul{
        margin-top: 40px;
    }
}
#lower:hover{
    color: yellow;
    cursor: pointer;
}
a .lower{
    margin-left: 60px;
   
   
}
.lower:after{
    background: none repeat scroll 0 0 transparent;
    bottom: 0;
    content: "";
    display: block;
    height: 2px;
    left: 50%;
    position: absolute;
    background: rgb(249, 253, 6);
    transition: width 0.3s ease 0s, left 0.3s ease 0s;
    width: 0px;
}
.lower:hover:after{
    width: 65%;
    left: 18%;
}
#media screen and (max-height:300px){
    .two{
        margin-top: 40px;
       
    }
}
h1{
    text-align: center;
    justify-content: center center;
    font-size: 50px;
    font-weight: 900;
    padding: 150px 5px 5px 5px;
    background:linear-gradient(to left, yellow, white);
    -webkit-background-clip:text;
    -webkit-text-fill-color: transparent;
}
p{
    background-color: white;
    text-align: center;
    -webkit-background-clip:text;
    -webkit-text-fill-color: transparent;
}
.btn{
    border: none;
    background-color: darkgoldenrod;
    color: white;
    border-radius: 25px;
    width: 110px;
    height: 30px;
    font-size: 12px;
    font-weight: 600; 
    justify-content: center center;
    margin: auto;
    outline: none;
    }
.btn:hover{
    background-color: yellow;
    color: rgb(15, 12, 12);
    cursor: pointer;
}
.lower_section{
    bottom: 0;
    z-index: 1;
    height: 100px;
    width: 100%;
    position: absolute;
    /* padding-top: 40px;
    padding-bottom: 40px; */
    
   /* justify-content: center;
   text-align: center center; */
   
}
.lower_section::before{
    content: "";
    z-index: -1;
    bottom: 0;
    height:120px;
   width: 100%;
   text-align: center;
   position: absolute;
   background-color: black;
   filter: brightness(0%);
   opacity:0.5;
   align-items: center;
    justify-content: center center;
}
/* .sub_lower{  
   margin-top: -15px;
    position: relative;
    width: 85%;
    height: 50px;
    color: yellow; 
     background-color: yellow;
    content: "";
    z-index: 1;
    text-align: center;
    justify-content: space-around;
} */
   .sub_lower a{
       display: inline-flex;
    position: relative;
     width: 20px;
     height: 20px;
    margin:2px;
    padding-right:100px;
    padding-left: 100px;
    color: white;
    background-color: grey;
    text-align: center;
    justify-content: center;
    justify-items: center center; 
} 
.contain{
   
    position: relative;
   max-width: 300px;
    /* height: fit-content; */
}
/* #media only screen and (min-device-width:400px)
{
    .box{
        max-width: 400px;
    }
} */
.box{
    display: flex;
    flex-shrink: initial;
   width: 300px;
    height: 300px;
    position: absolute;
}
.red{
    z-index: 1;
    background-color: red;
}
.blue{
   z-index: 2;   
    background-color: blue;
   top: 200px;
   left: 200px;
}
ADDED:
#media screen and (max-width:576px){
.contain{
max-width: unset;
}
.blue{
left: unset;
right: 0;
}
}
*{
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
body{
background-color: white;
background-attachment: scroll;
min-width: 100%;
}
.head_section{
position: relative;
z-index: 1;
height: 32rem;
width: 100%;
background-color: black;
}
.head_section::before{
content: "";
z-index: -1;
position: absolute;
height: 32rem;
width: 100%;
color: black;
background-image: url(image/pexels-birgit-held-1046125.jpg);
background-position: center;
background-attachment: fixed;
background-size: cover;
opacity: 0.6;
}
/*
#top_layout{
padding:5px 0 5px 0;
text-align: center;
justify-content: center;
} */
ul{
margin: auto 0px;
padding: 0px;
list-style: none;
display: table;
width: 80%;
text-align: center;
/* background-color: red; */
}
.two{
margin: auto 0px;
padding-bottom: 40px;
list-style: none;
display: table;
width: 80%;
text-align: center;
top: 0px;
}
li{
display: table-cell;
position: relative;
padding: 5px 10px 5px 12px;
text-transform: uppercase;
font-size: 13px;
letter-spacing: 0.15em;
display: inline-block;
position: relative;
/* background-color: blue; */
}
#lower{
display: table-cell;
padding: 10px 13px 40px 15px;
/* background-color: blue; */
text-transform: uppercase;
font-size: 15px;
letter-spacing: 0.15em;
position: relative ;
/* padding-top: 50px; */
position: 0;
}
a{
padding: 5px 10px;
color: white;
text-decoration: none;
top: 0px;
/* background-color: grey; */
margin-bottom: 20px;
}
a:hover{
color: yellow;
cursor: pointer;
}
a:after{
background: none repeat scroll 0 0 transparent;
bottom: 0;
content: "";
display: block;
height: 2px;
left: 50%;
position: absolute;
background: yellow;
transition: width 0.3s ease 0s, left 0.3s ease 0s;
width: 0px;
}
a:hover:after{
width: 100%;
left: 0;
}
#media screen and (max-height:300px){
ul{
margin-top: 40px;
}
}
#lower:hover{
color: yellow;
cursor: pointer;
}
a .lower{
margin-left: 60px;
}
.lower:after{
background: none repeat scroll 0 0 transparent;
bottom: 0;
content: "";
display: block;
height: 2px;
left: 50%;
position: absolute;
background: rgb(249, 253, 6);
transition: width 0.3s ease 0s, left 0.3s ease 0s;
width: 0px;
}
.lower:hover:after{
width: 65%;
left: 18%;
}
#media screen and (max-height:300px){
.two{
margin-top: 40px;
}
}
h1{
text-align: center;
justify-content: center center;
font-size: 50px;
font-weight: 900;
padding: 150px 5px 5px 5px;
background:linear-gradient(to left, yellow, white);
-webkit-background-clip:text;
-webkit-text-fill-color: transparent;
}
p{
background-color: white;
text-align: center;
-webkit-background-clip:text;
-webkit-text-fill-color: transparent;
}
.btn{
border: none;
background-color: darkgoldenrod;
color: white;
border-radius: 25px;
width: 110px;
height: 30px;
font-size: 12px;
font-weight: 600;
justify-content: center center;
margin: auto;
outline: none;
}
.btn:hover{
background-color: yellow;
color: rgb(15, 12, 12);
cursor: pointer;
}
.lower_section{
bottom: 0;
z-index: 1;
height: 100px;
width: 100%;
position: absolute;
/* padding-top: 40px;
padding-bottom: 40px; */
/* justify-content: center;
text-align: center center; */
}
.lower_section::before{
content: "";
z-index: -1;
bottom: 0;
height:120px;
width: 100%;
text-align: center;
position: absolute;
background-color: black;
filter: brightness(0%);
opacity:0.5;
align-items: center;
justify-content: center center;
}
/* .sub_lower{
margin-top: -15px;
position: relative;
width: 85%;
height: 50px;
color: yellow;
background-color: yellow;
content: "";
z-index: 1;
text-align: center;
justify-content: space-around;
} */
.sub_lower a{
display: inline-flex;
position: relative;
width: 20px;
height: 20px;
margin:2px;
padding-right:100px;
padding-left: 100px;
color: white;
background-color: grey;
text-align: center;
justify-content: center;
justify-items: center center;
}
.contain{
position: relative;
max-width: 300px;
/* height: fit-content; */
}
/* #media only screen and (min-device-width:400px)
{
.box{
max-width: 400px;
}
} */
.box{
display: flex;
flex-shrink: initial;
width: 300px;
height: 300px;
position: absolute;
}
.red{
z-index: 1;
background-color: red;
}
.blue{
z-index: 2;
background-color: blue;
top: 200px;
left: 200px;
}
#media screen and (max-width:576px){
.contain{
max-width: unset;
}
.blue{
left: unset;
right: 0;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Acadera Renewed</title>
<link rel="stylesheet" href="Acadera Imp.css">
</head>
<body>
<div class="head_section">
<div id="top_layout">
<center>
<ul>
<li><a>Home</a></li>
<li><a>Pages</a></li>
<li> <a>Services</a></li>
<li><a>Gallary</a></li>
<li><a>Blog</a></li>
<li><a>Contact</a></li>
<li><a>About</a></li>
<li><input type="text" placeholder="Search"></input></li>
</ul>
</center>
</div>
<h1>WELCOME TO ACADERA</h1>
<p>We bring you the best there is to offer</p>
<center><input type="button" class= "btn" value="GET STARTED" ></input></center>
<div class="lower_section">
<center>
<ul class="two">
<li id="lower">Akan</li>
<li id="lower">Uwem</li>
<li id="lower">Itoro</li>
</ul>
</center>
</div>
</div>
<div class="contain">
<div class="box red"> </div>
<div class="box blue"></div>
</div>
</body>
</html>

Is there a way to scale down an image, preserving its ratio, inside a div element using CSS correctly?

I've been having trouble fitting images into a <div> element on my site. I've tried several different methods, including setting max-width and max-height to 100%, changing the object that it's contained inside to display as a flex object, and various different object-fit parameters. Is there something that I'm missing here, or is it impossible to do this?
openModal();
function openModal() {
modal.style.display = "flex";
var t = setTimeout(transitionOpenModal, 30);
}
function transitionOpenModal() {
modal.style.opacity = "1";
modalContainer.style.transform = "scale(100%)";
modalContainer.style.webkitTransform = "scale(1)";
}
function closeModal() {
modalContainer.style.transform = "scale(0%)";
modalContainer.style.webkitTransform = "scale(0)";
modal.style.opacity = "0";
var t = setTimeout(closeModalAfterTransition, 250);
}
function closeModalAfterTransition() {
modal.style.display = "none";
}
/* MODAL DIALOG */
.modal {
display: none;
opacity: 0;
position: fixed;
z-index: 99;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
transition: opacity 0.25s;
justify-content: center;
align-items: center;
}
.modal-header {
position: sticky;
padding-bottom: 16px;
}
.modal-container {
background-color: white;
border-radius: 4px;
margin-left: auto;
margin-right: auto;
padding: 16px;
max-width: 80vw;
max-height: 80vh;
filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.25));
transform: scale(0%);
-webkit-transform: scale(0);
transition: transform 0.25s;
}
.modal-content {
max-width: 100%;
max-height: 100%;
}
img.modal-content-inner {
max-width: 100%;
max-height: auto;
object-fit: contain;
}
.modal-header>h2 {
display: inline;
}
.modal-close {
float: right;
font-size: 24px;
font-weight: bold;
}
.modal-close:hover,
.modal-close:focus {
text-decoration: none;
cursor: pointer;
}
<div id="modal" class="modal">
<div class="modal-container" id="modal-container">
<div class="modal-header">
<h2 id="modal-title">modal</h2>
<span class="modal-close" id="modal-close">×</span>
</div>
<div class="modal-content" id="modal-content">
<img src="https://via.placeholder.com/1920x1080.png">
<!-- this is a test case, please try with multiple image sizes -->
</div>
</div>
</div>
Here's what it currently looks like on my site.
Setting the img max-width:100% should do the trick. This will constrain it to the width of the containing div. Here's a stripped down version of what you have.
.modal {
/* display: none; */
/* opacity: 0; */
position: fixed;
z-index: 99;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-color: rgba(0,0,0,0.5);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
transition: opacity 0.25s;
justify-content: center;
align-items: center;
}
.modal-header {
position: sticky;
padding-bottom: 16px;
}
.modal-container {
background-color: white;
border-radius: 4px;
margin-left: auto;
margin-right: auto;
padding: 16px;
max-width: 80vw;
/* max-height: 80vh; */
filter: drop-shadow(0 4px 4px rgba(0,0,0,0.25));
/* transform: scale(0%);
-webkit-transform: scale(0);
transition: transform 0.25s; */
}
.modal-content {
width: 100%;
height: 100%;
}
.modal-content > img {
max-width: 100%;
}
.modal-header > h2 {
display: inline;
}
.modal-close {
float: right;
font-size: 24px;
font-weight: bold;
}
.modal-close:hover, .modal-close:focus {
text-decoration: none;
cursor: pointer;
}
<div id="modal" class="modal">
<div class="modal-container" id="modal-container">
<div class="modal-header">
<h2 id="modal-title">modal</h2>
<span class="modal-close" id="modal-close">×</span>
</div>
<div class="modal-content" id="modal-content">
<img src="https://via.placeholder.com/1920x1080.png">
</div>
</div>
</div>
Figured this one out on my own—turns out I could just set the max-width and max-height of the image itself.

CSS background layers bug

I am trying to implement button I took from codepen on my existing "box-list" div.
But in my form the button gets fathers background and I cant perform my original button blue background as it should be.
On the bottom of the page you can see the button outside the "box-list" how it should look.
<link rel="stylesheet" type="text/css" href="style.css">
<div class="box-list">
<!-- FREE TEXT BOX -->
<div class="box" >
<div class="box__inner">
<h1>Free Text</h1>
Get you free text processed and analyzed, and get opinion summery about.
<button class="analyzeBtn mybtn1" >hover</button>
</div>
</div>
<!-- TWITTER BOX -->
<div class="box" >
<div class="box__inner">
<h1>Twitter Search</h1>
Get Twitter post and comments about any subject you choose and analyze the dat
</div>
</div>
<div class="box" >
<div class="box__inner">
<h1>URL</h1>
Get your URL article analyzed
</div>
</div>
</div>
<button class="analyzeBtn mybtn1" >hover</button>
.box-list {
background: #119bc9;
overflow: hidden;
display: flex;
}
.box {
min-height: 300px;
color: #fff;
transition: all 0.5s;
max-height: 300px;
background-image: url('http://lorempixel.com/400/300/sports');
background-size: cover;
width: 33.33%;
}
.box__inner {
padding: 20px;
min-height: 300px;
background-color: rgba(17, 155, 201, 0.7);
}
.box:hover {
width: 150%!important;
font-size: 18px;
}
.box:nth-child(odd) {
background-image: url('/images/text.jpg');
}
.box:nth-child(odd) .box__inner{
background: rgba(71, 83, 157, 0.8);
}
.analyzeBtn {
border: 1px solid #3498db;
background: none;
padding: 10px 20px;
font-size: 20px;
font-family: "montserrat";
margin: 10px;
transition: 0.8s;
position: relative;
cursor: pointer;
overflow: hidden;
border-radius: 5px;
}
.mybtn1 {
color: #fff;
}
.mybtn1:hover {
color: #3498db;
transform: translateY(-7px);
transition: 0.4s;
}
.analyzeBtn::before {
content: "";
position: absolute;
left: 0;
width: 100%;
height: 0%;
background: #3498db;
z-index: -1;
transition: 0.6s;
}
.mybtn1::before {
top:0;
border-radius: 0 0 50% 50%;
height: 180%;
}
.mybtn1:hover::before {
height: 0%;
}
JSfiddle example
You need to add z-index: 1; to the button so that it is displayed on top of the backgrounds:
.analyzeBtn {
border: 1px solid #3498db;
background: none;
padding: 10px 20px;
font-size: 20px;
font-family: "montserrat";
margin: 10px;
transition: 0.8s;
position: relative;
cursor: pointer;
overflow: hidden;
border-radius: 5px;
z-index: 1;
}

I have a code and i need change "a" tag to "li". When i do it css animation stop work

I want to change (a) tag to (li). When i do it css animation stop working. Why? It is not first time when i change (a) tag to (li) but i never have problem like this. Of course you need to do manipulations in css but this time i can not solve this problem. How can i change it?
<div class="panel" id="slice">
<div class="panel__content">
Close me.
</div>
</div>
<div class="menu">
<a class="menu__link" href="#slice" data-hover="Slice">Slice</a>
</div>
.menu {
position: fixed;
width: 100vw;
pointer-events: none;
margin-top: 10vh;
text-align: center;
z-index: 2; }
.menu__link {
display: inline-block;
text-decoration: none;
border: 2px solid #263238;
color: #263238;
pointer-events: auto;
line-height: 40px;
position: relative;
padding: 0 50px;
box-sizing: border-box;
margin: 0;
user-select: none;
overflow: hidden;
border-radius: 50px;
.panel {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: auto;
z-index: 999;
color: #000;
box-sizing: border-box;
background-color: #ECEFF1; }
.panel__content {
opacity: 0;
will-change: margin-top;
transition: all 700ms;
transition-delay: 600ms;
padding: 100px 200px;
margin-top: -5%; }
.panel:target .panel__content {
opacity: 1;
margin-top: 0; }
.panel#slice {
background-color: #E53935;
transition: all 800ms cubic-bezier(0.190, 1.000, 0.560, 1.000);
transform: translate3d( 0, -100%, 0 ); }
.panel#slice:target {
transform: translate3d( 0, 0, 0 ); }
You'd have to restyle the unordered list for spacing, but maybe instead of outright replacing your menu's <a> elements with <li>, you could include the <a> elements in the resulting list items.
This would preserve all the :target functionality and give you the list (for semantics?).
EDIT: Of course, this won't do at all if your menu just can not consist of anything but <li>.
/* basic style definition */
/* •••••••••••••••••••••••••••••••• */
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: 'Roboto Slab', serif;
}
h1 {
margin: 0;
user-select: none;
text-align: center;
font-weight: 300;
}
p,
{
font-weight: 300;
color: #546E7A;
user-select: none;
text-align: center;
margin: 0;
}
a {
text-align: center;
text-decoration: none;
color: #FFF;
}
/* Navigation menu */
/* •••••••••••••••••••••••••••••••• */
.menu {
position: fixed;
width: 100vw;
pointer-events: none;
margin-top: 10vh;
text-align: center;
z-index: 2;
}
/* Menu link item */
.menu__link {
display: inline-block;
text-decoration: none;
border: 2px solid #263238;
color: #263238;
pointer-events: auto;
line-height: 40px;
position: relative;
padding: 0 50px;
box-sizing: border-box;
margin: 0;
user-select: none;
overflow: hidden;
border-radius: 50px;
&::before {
content: attr(data-hover);
background-color: #263238;
color: #FFF;
position: absolute;
top: 100%;
bottom: 0;
left: 0;
transition: all 300ms cubic-bezier(0.190, 1.000, 0.560, 1.000);
right: 0;
}
&:hover::before {
top: 0;
}
}
/* Panels Style*/
/* •••••••••••••••••••••••••••••••• */
/* Common panel style */
.panel {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: auto;
z-index: 999;
color: #000;
box-sizing: border-box;
background-color: #ECEFF1;
}
/* panel content (only for animation delay after open) */
.panel__content {
opacity: 0;
will-change: margin-top;
transition: all 700ms;
transition-delay: 600ms;
padding: 100px 200px;
margin-top: -5%;
}
/* Panel content animation after open */
.panel:target .panel__content {
opacity: 1;
margin-top: 0;
}
/* Specific "Home "panel */
/* •••••••••••••••••••••••••••••••• */
.panel#home {
z-index: 1;
background: radial-gradient(ellipse at center, rgba(255, 255, 255, 1) 0%, #CFD8DC 100%);
}
/* Specific panel "Slice" */
/* •••••••••••••••••••••••••••••••• */
.panel#slice {
background-color: #E53935;
transition: all 800ms cubic-bezier(0.190, 1.000, 0.560, 1.000);
transform: translate3d( 0, -100%, 0);
}
.panel#slice:target {
transform: translate3d( 0, 0, 0);
}
/* Specific panel "Fade" effect */
/* •••••••••••••••••••••••••••••••• */
.panel#fade {
background-color: #00C853;
opacity: 0;
transition: all 800ms;
pointer-events: none;
}
.panel#fade:target {
opacity: 1;
pointer-events: auto;
}
<!-- Home Panel -->
<div class="panel" id="home">
<h1>Pure CSS panels</h1>
<p>by Mattia Astorino</p>
</div>
<div class="panel" id="slice">
<div class="panel__content">
<a href="#home">
Close me.
</a>
</div>
</div>
<div class="panel" id="fade">
<div class="panel__content">
Close me.
</div>
</div>
<!-- Navigation -->
<div class="menu">
<ul>
<li>
<a class="menu__link" href="#slice" data-hover="Slice">Slice</a>
</li>
<li>
<a class="menu__link" href="#fade" data-hover="Fade">Fade</a>
</li>
</ul>
</div>

divider not showing with onhover effects

I am just attempting a simple fix. For some reason my divider isn't showing up on hover? How can I get it to show up like the other text does? I have another example of how i got the divider to look on other pages...
http://runningfish.net/finestc/about/
Right underneath the header of the page that says "About"
Also, what I am currently working with is runningfish.net/finestc
You can see the live code there right underneath the section that says "Recent Sales".
I am still a fledgling coder so if I am doing something inefficiently or could be doing better that you notice, please point it out! I want to get better at coding. Critique welcome!
Thanks!
.grids {
width: 33.33%;
float: left;
display: inline-block;
position: relative;
}
.grids img {
display: block;
height: 33.33vh;
width: 100%;
}
.grid-image-description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
color: #fff;
visibility: hidden;
opacity: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: opacity .5s, visibility .5s;
}
.grid-image-description h2 {
font-family: playfairdisplay;
font-size: 1.7em;
color: #fff;
}
.grid-image-description p {
font-family: playfairdisplay;
font-size: 1.0em;
color: #fff;
}
.grid-image-description hr {
border-top: 1px;
border-color: #001532;
border-style: solid;
box-shadow: 2px 1px 15px #fff;
margin: 0 0 0 10px;
max-width: 200px;
}
.grids:hover .grid-image-description {
visibility: visible;
opacity: 1;
}
.grids-description {
transition: .5s;
transform: translateY(1em);
}
.grids:hover .grid-image-description {
transform: translateY(0);
}
<a href="#nogo">
<div class="grids">
<img class="grid-image-cover" alt="" src="//runningfish.net/finestc/wp-content/uploads/2018/02/Depositphotos_11636543_original.jpg" />
<div class="grid-image-description">
<h2 class="grids-header">House For Sale</h2>
<hr>
<p class="grids-description">123 mulbury street</br>san diego, ca 92101
</p>
</div>
</div>
</a>
Add a width value to <hr>
.grids {
width: 33.33%;
float: left;
display: inline-block;
position: relative;
}
.grids img {
display: block;
height: 33.33vh;
width: 100%;
}
.grid-image-description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
color: #fff;
visibility: hidden;
opacity: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: opacity .5s, visibility .5s;
}
.grid-image-description h2 {
font-family: playfairdisplay;
font-size: 1.7em;
color: #fff;
}
.grid-image-description p {
font-family: playfairdisplay;
font-size: 1.0em;
color: #fff;
}
.grid-image-description hr {
border-top: 1px;
border-color: #001532;
border-style: solid;
box-shadow: 2px 1px 15px #fff;
margin: 0 0 0 10px;
max-width: 200px;
/* added */
width: 200px;
}
.grids:hover .grid-image-description {
visibility: visible;
opacity: 1;
}
.grids-description {
transition: .5s;
transform: translateY(1em);
}
.grids:hover .grid-image-description {
transform: translateY(0);
}
<a href="#nogo">
<div class="grids">
<img class="grid-image-cover" alt="" src="//runningfish.net/finestc/wp-content/uploads/2018/02/Depositphotos_11636543_original.jpg" />
<div class="grid-image-description">
<h2 class="grids-header">House For Sale</h2>
<hr>
<p class="grids-description">123 mulbury street<br>san diego, ca 92101
</p>
</div>
</div>
</a>