How to add closing effect with CSS Keyframe animation dropdown - html

I am trying to add a close effect with Keyframe css to the dropdown menu. I have succeeded with the opening, but I cannot do the same with the close. If you take a look you see the animation on entry, but on exit the menu simply disappears.
Sorry but I'm relatively new, someone kindly explain to me what I'm doing wrong?
I know that I can achieve the same result also with Javascript, but I would like to obtain the result only with css and understand if this is possible.
Updated Snippet: I was looking for an alternative to visibility property because even with hidden menu I have the "ghost container" in front of other elements. I was thinking about display none to block and keyframe animation, but this did not allow me to add a closing effect. Anyway I kept visibility and solved the "ghost container" with height property.
var usermenu = document.querySelector(".user_menu_button");
function userMenu() {
var x = document.getElementById("mts_menu");
if (x.classList.toggle ("show")) {
usermenu.innerHTML = '<i class="icn_button fa-solid fa-xmark"></i><span class="txt_button">Account</span>';
} else {
usermenu.innerHTML = '<i class="icn_button fa-solid fa-bars"></i><span class="txt_button">Account</span>';
}
}
/*Items menu*/
.user_menu {
display: flex;
flex-direction: column;
}
/*Menu header info*/
.display.name {
font-size: 15px;
font-weight: 500;
color: #303238;
}
.display.mail {
font-size: 13px;
color: #3d5afe;
}
hr.solid {
border-top: 1px solid #e0e0e0;
margin: 10px 0px 10px 0px;
}
/*Text Link css*/
.user_menu.item > a {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 8px 0;
font-size: 13px;
color: #75777D;
}
.user_menu.item:hover > a {
color: #2E323A;
}
/*Icon Button Toggle Menu*/
.user_menu_button {
display: flex;
align-content: center;
justify-content: center;
align-items: center;
width: 100%;
background: #282c33!important;
font-weight: 500!important;
font-size: 13px!important;
}
.icn_button {
margin: 0;
}
.icn_button:before, .icn_button:after {
margin: 0;
}
.txt_button {
margin-left: 10px;
}
/*Icon Items Menu*/
.icn_menu:before, .icon_menu:after {
margin: 0px;
padding: 0px;
font-size: 16px
}
.icn_menu {
margin-right: 10px;
display: flex !important;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
}
/* User Menu For header website */
.mts_menu_container {
display: flex;
flex-direction: column;
align-content: flex-end;
align-items: flex-end;
}
.dropdown_box {
position: absolute;
margin-top: 17px;
}
.mnu_padding {
padding: 20px;
}
.mts_dropdown_content {
background-color: #fff;
min-width: 160px;
width: 280px;
border-radius: 3px;
overflow-x: hidden;
overflow-y: hidden;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 999;
position: relative;
visibility: hidden;
opacity: 0;
top: 50px;
height: 0;
transition: visibility 0.2s, max-height 0.2s, opacity 0.2s, top 0.2s, height 0.2s;
}
.mts_dropdown_content.show {
height: 100%;
visibility: visible;
opacity: 1;
top: 0;
transition: visibility 0.2s, max-height 0.2s, opacity 0.2s, top 0.2s, height 0.2s;
}
<button onclick="userMenu()" class="user_menu_button">
<i class="icn_button fa-solid fa-bars"></i>
<span class="txt_button">Account</span>
</button>
<div class="mts_menu_container">
<div class="dropdown_box">
<div id="mts_menu" class="mts_dropdown_content">
<div class="mnu_padding">
<div class="user_menu header">
<span class="display name">Ciao [display_name]</span>
<span class="display mail">[display_email]</span>
</div>
<hr class="solid">
<div class="user_menu item">
<a href="/account">
<i class="icn_menu fa-regular fa-user"></i>
<span class="link_text">Dashboard</span>
</a>
</div>
<div class="user_menu item">
<a href="ordini">
<i class="icn_menu fa-regular fa-basket-shopping"></i>
<span class="link_text">I miei ordini</span>
</a>
</div>
<div class="user_menu item">
<a href="libreria">
<i class="icn_menu fa-regular fa-cloud-arrow-down"></i>
<span class="link_text">Downloads</span>
</a>
</div>
<div class="user_menu item">
<a href="impostazioni">
<i class="icn_menu fa-regular fa-gear"></i>
<span class="link_text">Impostazioni</span>
</a>
</div>
<div class="user_menu item">
<a href="wp-login.php?action=logout">
<i class="icn_menu fa-regular fa-arrow-right-from-bracket"></i>
<span class="link_text">Logout</span>
</a>
</div>
</div>
</div>
</div>
</div>
Original Snippet
var usermenu = document.querySelector(".user_menu_button");
function userMenu() {
var x = document.getElementById("mts_menu");
if (x.classList.toggle ("show")) {
usermenu.innerHTML = '<i class="icn_button fa-solid fa-xmark"></i><span class="txt_button">Account</span>';
} else {
usermenu.innerHTML = '<i class="icn_button fa-solid fa-bars"></i><span class="txt_button">Account</span>';
}
}
/*Items menu*/
.user_menu {
display: flex;
flex-direction: column;
}
/*Menu header info*/
.display.name {
font-size: 15px;
font-weight: 500;
color: #303238;
}
.display.mail {
font-size: 13px;
color: #3d5afe;
}
hr.solid {
border-top: 1px solid #e0e0e0;
margin: 10px 0px 10px 0px;
}
/*Text Link css*/
.user_menu.item > a {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 8px 0;
font-size: 13px;
color: #75777D;
}
.user_menu.item:hover > a {
color: #2E323A;
}
/*Icon Button Toggle Menu*/
.user_menu_button {
display: flex;
align-content: center;
justify-content: center;
align-items: center;
width: 100%;
background: #282c33!important;
font-weight: 500!important;
font-size: 13px!important;
}
.icn_button {
margin: 0;
}
.icn_button:before, .icn_button:after {
margin: 0;
}
.txt_button {
margin-left: 10px;
}
/*Icon Items Menu*/
.icn_menu:before, .icon_menu:after {
margin: 0px;
padding: 0px;
font-size: 16px
}
.icn_menu {
margin-right: 10px;
display: flex !important;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
}
/* User Menu For header website */
.mts_menu_container {
display: flex;
flex-direction: column;
align-content: flex-end;
align-items: flex-end;
}
.dropdown_box {
position: absolute;
margin-top: 17px;
}
.mnu_padding {
padding: 20px;
}
.mts_dropdown_content {
background-color: #fff;
min-width: 160px;
width: 280px;
border-radius: 3px;
overflow-x: hidden;
overflow-y: hidden;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 999;
position: relative;
display: none;
animation: fade_in_hide 0.2s;
}
.mts_dropdown_content.show {
display: block;
animation: fade_in_show 0.2s;
}
#keyframes fade_in_show {
0% {
opacity: 0;
top: 50px;
}
100% {
opacity: 1;
top: 0;
}
}
#keyframes fade_in_hide {
0% {
opacity: 1;
top: 0;
}
100% {
opacity: 0;
top: 50px;
}
}
<button onclick="userMenu()" class="user_menu_button">
<i class="icn_button fa-solid fa-bars"></i>
<span class="txt_button">Account</span>
</button>
<div class="mts_menu_container">
<div class="dropdown_box">
<div id="mts_menu" class="mts_dropdown_content">
<div class="mnu_padding">
<div class="user_menu header">
<span class="display name">Ciao [display_name]</span>
<span class="display mail">[display_email]</span>
</div>
<hr class="solid">
<div class="user_menu item">
<a href="/account">
<i class="icn_menu fa-regular fa-user"></i>
<span class="link_text">Dashboard</span>
</a>
</div>
<div class="user_menu item">
<a href="ordini">
<i class="icn_menu fa-regular fa-basket-shopping"></i>
<span class="link_text">I miei ordini</span>
</a>
</div>
<div class="user_menu item">
<a href="libreria">
<i class="icn_menu fa-regular fa-cloud-arrow-down"></i>
<span class="link_text">Downloads</span>
</a>
</div>
<div class="user_menu item">
<a href="impostazioni">
<i class="icn_menu fa-regular fa-gear"></i>
<span class="link_text">Impostazioni</span>
</a>
</div>
<div class="user_menu item">
<a href="wp-login.php?action=logout">
<i class="icn_menu fa-regular fa-arrow-right-from-bracket"></i>
<span class="link_text">Logout</span>
</a>
</div>
</div>
</div>
</div>
</div>

Since you don't want to go the JS route, transitions would be easier here. However, you can't transition display so you'll need to swap that out for visibility and have your menu display set to block from the start and just hide it with visibility and opacity.
var usermenu = document.querySelector(".user_menu_button");
function userMenu() {
var x = document.getElementById("mts_menu");
if (x.classList.toggle("show")) {
usermenu.innerHTML = '<i class="icn_button fa-solid fa-xmark"></i><span class="txt_button">Account</span>';
} else {
usermenu.innerHTML = '<i class="icn_button fa-solid fa-bars"></i><span class="txt_button">Account</span>';
}
}
/*Items menu*/
.user_menu {
display: flex;
flex-direction: column;
}
/*Menu header info*/
.display.name {
font-size: 15px;
font-weight: 500;
color: #303238;
}
.display.mail {
font-size: 13px;
color: #3d5afe;
}
hr.solid {
border-top: 1px solid #e0e0e0;
margin: 10px 0px 10px 0px;
}
/*Text Link css*/
.user_menu.item>a {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 8px 0;
font-size: 13px;
color: #75777D;
}
.user_menu.item:hover>a {
color: #2E323A;
}
/*Icon Button Toggle Menu*/
.user_menu_button {
display: flex;
align-content: center;
justify-content: center;
align-items: center;
width: 100%;
background: #282c33 !important;
font-weight: 500 !important;
font-size: 13px !important;
}
.icn_button {
margin: 0;
}
.icn_button:before,
.icn_button:after {
margin: 0;
}
.txt_button {
margin-left: 10px;
}
/*Icon Items Menu*/
.icn_menu:before,
.icon_menu:after {
margin: 0px;
padding: 0px;
font-size: 16px
}
.icn_menu {
margin-right: 10px;
display: flex !important;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
}
/* User Menu For header website */
.mts_menu_container {
display: flex;
flex-direction: column;
align-content: flex-end;
align-items: flex-end;
}
.dropdown_box {
position: absolute;
margin-top: 17px;
}
.mnu_padding {
padding: 20px;
}
.mts_dropdown_content {
background-color: #fff;
min-width: 160px;
width: 280px;
border-radius: 3px;
overflow-x: hidden;
overflow-y: hidden;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: -1;
opacity: 0;
top: 50px;
position: relative;
display: block;
visibility: none;
transition: opacity, top, 0.2s linear;
}
.mts_dropdown_content.show {
opacity: 1;
top: 0px;
z-index: 999;
visibility: visible;
transition: opacity, top, 0.2s linear;
}
#keyframes fade_in_show {
0% {
opacity: 0;
top: 50px;
}
100% {
opacity: 1;
top: 0;
}
}
#keyframes fade_in_hide {
0% {
opacity: 1;
top: 0;
}
100% {
opacity: 0;
top: 50px;
}
}
<button onclick="userMenu()" class="user_menu_button">
<i class="icn_button fa-solid fa-bars"></i>
<span class="txt_button">Account</span>
</button>
<div class="mts_menu_container">
<div class="dropdown_box">
<div id="mts_menu" class="mts_dropdown_content">
<div class="mnu_padding">
<div class="user_menu header">
<span class="display name">Ciao [display_name]</span>
<span class="display mail">[display_email]</span>
</div>
<hr class="solid">
<div class="user_menu item">
<a href="/account">
<i class="icn_menu fa-regular fa-user"></i>
<span class="link_text">Dashboard</span>
</a>
</div>
<div class="user_menu item">
<a href="ordini">
<i class="icn_menu fa-regular fa-basket-shopping"></i>
<span class="link_text">I miei ordini</span>
</a>
</div>
<div class="user_menu item">
<a href="libreria">
<i class="icn_menu fa-regular fa-cloud-arrow-down"></i>
<span class="link_text">Downloads</span>
</a>
</div>
<div class="user_menu item">
<a href="impostazioni">
<i class="icn_menu fa-regular fa-gear"></i>
<span class="link_text">Impostazioni</span>
</a>
</div>
<div class="user_menu item">
<a href="wp-login.php?action=logout">
<i class="icn_menu fa-regular fa-arrow-right-from-bracket"></i>
<span class="link_text">Logout</span>
</a>
</div>
</div>
</div>
</div>
</div>

Related

Images are not displaying properly on Iphones

I have a problem. Specifically with my images on my site. When I see my site on Android phone, images displays normally without any issues. iPhone displays it like "stretched" to height. I would love to get help, how to fix this problem. I tried some ways how to avoid that, but I found nothing. Sorry for long code. Here are pictures for visualization:
IPhone Image
Android Image
#import url('https://fonts.googleapis.com/css2?family=Commissioner:wght#400;500;700&display=swap');
:root {
--main-font: Commissioner;
--main-font-weight: 500;
--color-background-first: #1D201F;
--color-content-red: #C58882;
--color-content-yellow: #EAD2AC;
--color-content-blue: #D1DEDE;
--color-content-pink: #DF928E;
--color-background-second: #404040;
}
* {
font-family: var(--main-font);
font-weight: var(--main-font-weight);
margin: 0;
padding: 0;
}
html {
box-sizing: border-box;
}
#navbar {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
background-color: var(--color-background-second);
width: 100%;
height: 5rem;
box-shadow: 0px 5px 10px 2px black;
margin-top: -3px;
}
#navbar>ul {
display: flex;
list-style-type: none;
font-size: 2.1rem;
min-height: 100%;
}
#navbar>ul>li {
padding: 1vw;
min-height: 100%;
display: flex;
align-items: center;
transition: ease-out 0.3s;
}
#navbar>ul>li>a {
text-decoration: none;
color: var(--color-content-red);
max-height: 100%;
}
li:hover {
background-color: rgba(0, 0, 0, 0.5);
}
#welcome-section {
display: flex;
align-items: center;
background-color: var(--color-background-first);
min-height: 100vh;
}
#welcome-section>div {
max-width: 65vh;
margin-left: 3vw;
margin-right: 3vw;
}
#welcome-section>div>h1 {
color: var(--color-content-yellow);
letter-spacing: 0.2em;
font-size: 4rem;
margin-top: 7rem;
}
#first-line {
color: var(--color-content-blue);
text-align: center;
letter-spacing: 0.2em;
margin: 2em auto 0 auto;
font-size: 3rem;
}
#second-line {
color: var(--color-content-pink);
text-align: center;
letter-spacing: 0.2em;
font-size: 2rem;
font-style: italic;
}
#project-link {
font-size: 15pt;
padding: 1rem;
border-radius: 3px;
border: none;
background-color: #404040;
color: white;
transition: ease-in-out 0.2s;
text-align: center;
}
#project-link:hover {
cursor: pointer;
background-color: var(--color-content-red);
}
#project-link>i {
transition: ease-in-out 0.2s;
}
#project-link:hover>i {
transform: translateX(5px);
}
#welcome-section>i {
font-size: 1500%;
color: var(--color-background-first);
}
#emoji {
margin: 0 auto;
transition: ease-in 0.5s;
}
#project-link:hover+#emoji {
color: var(--color-content-blue);
}
#projects {
min-height: 100%;
width: 100%;
background-color: var(--color-content-red);
display: flex;
justify-content: center;
}
tile-image {
aspect-ratio: 1 / 1;
}
#project-tiles-container {
display: grid;
grid-template-columns: repeat(2, minmax(2px, 500px));
grid-gap: 4rem;
max-width: 80%;
max-width: 1280px;
margin: 0 2rem 6rem 2rem;
justify-content: center;
padding-top: 3rem;
}
.tile-desc {
padding: 2rem;
text-align: center;
background-color: var(--color-background-first);
}
.project-tile {
display: flex;
flex-direction: column;
text-decoration: none;
color: var(--color-content-yellow);
font-size: 1.2em;
box-shadow: 0px 0px 30px 1px black;
}
.code {
font-size: 100%;
color: var(--color-background-first);
transition: ease-out 0.5s;
}
.align-right {
transform: translateX(20px);
}
.align-left {
transform: translateX(-20px);
}
.project-tile:hover .align-left {
transform: translateX(0px);
color: var(--color-content-blue);
}
.project-tile:hover .align-right {
transform: translateX(0px);
color: var(--color-content-blue);
}
#contact-section-container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
min-height: 100vh;
background-color: var(--color-content-yellow);
color: var(--color-background-second);
text-shadow: 2px 1px 0px var(--color-content-pink);
gap: 1vh;
}
#contact-section-container>div {
display: flex;
gap: 4rem;
font-size: 1.8rem;
max-width: 80%;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
#contact-section-container>div>div>a {
text-decoration: none;
color: var(--color-background-second);
}
#contact-section-container>div>h1 {
font-size: 4rem;
text-align: center;
}
#contact-section-container>div>div {
display: flex;
align-items: center;
}
.contact-icon {
font-size: 2rem;
}
#contact-section-container>div>div>a {
transition: ease-out 0.2s;
}
#contact-section-container>div>div>a:hover {
transform: translateY(8px);
}
#media only screen and (max-width: 1000px) {
#welcome-section {
display: flex;
flex-direction: column;
margin: auto;
justify-content: center;
width: 100%;
text-align: center;
gap: 3rem;
}
html {
font-size: 75%;
}
#welcome-section>div>h1 {
margin-top: 12rem;
}
#project-tiles-container {
display: grid;
grid-template-columns: repeat(2, minmax(2px, 500px));
grid-gap: 4rem;
max-width: 80%;
max-width: 1280px;
margin: 0 2rem 6rem 2rem;
justify-content: center;
padding-top: 3rem;
}
#projects {
font-size: 150%;
}
#contact-section-container>div {
font-size: 200%;
}
}
#media only screen and (max-width: 800px) {
#project-tiles-container {
display: grid;
grid-template-columns: repeat(1, minmax(50px, 350px));
grid-gap: 4rem;
width: 80%;
max-width: 1280px;
margin: 0 auto;
margin-bottom: 6rem;
justify-content: center;
align-items: center;
}
#projects {
font-size: 150%;
}
}
#media only screen and (max-width: 330px) {
html {
font-size: 50%;
}
#projects {
font-size: 200%;
}
}
<!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">
<script src="https://kit.fontawesome.com/7290e96d25.js" crossorigin="anonymous"></script>
<title>Robin Weiss</title>
</head>
<body>
<main id="main">
<nav id="navbar">
<ul>
<li>About</li>
<li>Projects</li>
<li>Contact</li>
</ul>
</nav>
<section id="welcome-section">
<div id="container-about">
<h1>Hello, welcome to my portfolio!</h1>
<p id="first-line">I’m Robin</p>
<p id="second-line">a web developer</p>
</div>
<a id="project-link" href="https://codepen.io/weissrobin">
See all projects! <i class="fa-solid fa-chevron-right "></i>
</a>
<i id="emoji" class="fa-regular fa-face-smile-wink code "></i>
</section>
<section id="projects">
<div id="project-tiles-container">
<a class="project-tile" target="_blank" href="https://codepen.io/weissrobin/full/OJQMRvd">
<img class="tile-image" src="https://i.pinimg.com/564x/81/4d/6c/814d6c2caabab89b3c2608db7a11a6ba.jpg" alt="">
<p class="tile-desc">
<i class="fa-solid fa-chevron-left icon code align-left"></i> Survey Form
<i class="fa-solid fa-chevron-right icon code align-right"></i>
</p>
</a>
<a class="project-tile" target="_blank" href="https://codepen.io/weissrobin/full/KKQdYQw">
<img class="tile-image" src="https://i.pinimg.com/564x/7d/54/d0/7d54d0a35d57de79dacfe8662661523f.jpg" alt="">
<p class="tile-desc">
<i class="fa-solid fa-chevron-left icon code align-left"></i> Tribute Page
<i class="fa-solid fa-chevron-right icon code align-right"></i>
</p>
</a>
<a class="project-tile" target="_blank" href="https://codepen.io/weissrobin/full/zYRreRR">
<img class="tile-image" src="https://i.pinimg.com/564x/5f/ea/74/5fea74ebc53df1b0ad3534a1523b1256.jpg" alt="">
<p class="tile-desc">
<i class="fa-solid fa-chevron-left icon code align-left"></i> Product Page
<i class="fa-solid fa-chevron-right icon code align-right"></i>
</p>
</a>
<a class="project-tile" href="">
<img class="tile-image" src="" alt="">
</a>
</div>
</section>
<section id="contacts">
<div id="contact-section-container">
<div>
<h1>Lets work together</h1>
</div>
<div>
<div>
<a target="_blank" href="https://www.facebook.com/robin.hubacek/">
<i class="fa-brands fa-facebook contact-icon"></i>Facebook
</a>
</div>
<div>
<a target="_blank" href="https://www.instagram.com/robiwei/">
<i class="fa-brands fa-instagram-square contact-icon"></i>Instagram
</a>
</div>
<div>
<a id="profile-link" target="_blank" href="https://github.com/WeissRobin">
<i class="fa-brands fa-github-square contact-icon"></i>GitHub
</a>
</div>
<div>
<a href="">
<i class="fa-solid fa-at contact-icon"></i>Send a mail
</a>
</div>
<div>
<a href="">
<i class="fa-solid fa-mobile-screen contact-icon"></i>Call me
</a>
</div>
</div>
</div>
</section>
</main>
</body>
</html>

Overflow hides the content

The problem is on the "container main" div, which has the overflow-y. When the <form> height gets increased and the overflow starts to work on the "container div", it's not possible to see the whole form and the top part gets hidden
I don't think it's normal behavior, I've been some hours at this problem and just can't solve it the way I wanted (by leaving the form centered with "container main" flexbox)
.form-background {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -999;
backdrop-filter: brightness(125%) hue-rotate(180deg) blur(10px);
background-color: rgba(0, 0, 0, .5)
}
body {
background-image: url(https://images.pexels.com/photos/1624600/pexels-photo-1624600.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260)
}
section {
height: 100vh;
display: flex;
flex-direction: column;
overflow: auto!important
}
.main.container {
flex-grow: 3;
height: auto;
padding: 0 50px;
overflow-y: scroll;
margin: 50px auto 50px auto;
display: flex;
align-items: center;
}
form {
width: 100%;
}
.edit {
width: 50%;
display: inline-block
}
.edit .input-file {
cursor: pointer
}
.edit.middle,
.edit.middle input {
width: 100%
}
.edit.custom-input {
width: 100%;
display: flex
}
.edit.right {
padding-left: 5px
}
.edit.left {
padding-right: 5px
}
.clickin {
margin: 15px 0
}
form>.box:nth-child(n+2) {
margin-top: 70px
}
.current-templates,
.mob {
display: none;
margin-top: 20px;
}
.current-templates .file {
padding: 10px;
font-size: 1.2rem
}
.current-templates .file:not(:first-child) {
margin-top: 20px
}
.current-templates .file,
.current-templates .options {
display: flex;
align-items: center
}
.current-templates .options {
width: 100%;
justify-content: space-around
}
.current-templates .file span {
white-space: nowrap
}
.current-templates .options {
margin-left: 30px;
list-style: none;
overflow: auto
}
.current-templates .options li {
padding: 4px 25px;
cursor: pointer;
white-space: nowrap;
text-align: center;
transition: background-color .2s var(--cubic-bezier)
}
.current-templates .options li:hover {
background-color: var(--hover-color)
}
.current-templates .options .opt[selected=true] {
background-color: rgba(18, 238, 102, .466)
}
.btn-wrapper {
width: 100%;
display: flex;
justify-content: center;
align-items: center
}
.btn-wrapper button {
padding: 10px;
font-size: 1.1rem;
cursor: pointer;
outline: 0;
border: solid #000 1px;
width: 200px;
margin-top: 30px
}
.btn-anim {
transition: background-color .2s var(--cubic-bezier), color .2s var(--cubic-bezier);
background-color: var(--input-color)
}
.btn-anim:hover {
background-color: var(--hover-color) !important;
color: #fff
}
.btn-anim-blocked:hover {
background-color: rgba(255, 110, 110, .363)!important;
color: #fff
}
.fas.fa-question {
font-size: .8rem;
margin-left: 15px;
cursor: pointer;
padding: 5px;
position: relative
}
.img {
position: absolute;
left: 100%;
top: 0;
visibility: hidden;
opacity: 0;
transform: translate(-50%, -150%);
transition: visibility .2s var(--cubic-bezier), opacity .2s var(--cubic-bezier), transform .2s var(--cubic-bezier)
}
button.refresh-options i {
background-color: transparent;
border: none;
border-radius: 100%;
padding: 5px 8px;
transition: transform 1s var(--cubic-bezier)
}
button.refresh-options {
background-color: transparent;
border: none;
padding: 8px;
font-size: 1rem;
cursor: pointer;
outline: 0;
display: none
}
.edit .input-file,
.edit input {
background-color: var(--input-color)
}
button.refresh-options:hover i {
transform: rotateZ(360deg)
}
.check-box {
margin: 15px 0 25px 1px;
display: flex;
align-items: center
}
.check-box .square {
position: relative;
width: 20px;
height: 20px;
background-color: transparent;
border: solid #fff 1px;
cursor: pointer
}
.check-box span {
margin-left: 20px
}
header {
position: fixed;
width: 100%;
background-color: transparent;
}
.container.nav-content {
padding: 0;
overflow: auto;
}
.container.nav-content {
grid-template-columns: auto 1fr;
justify-content: space-between;
}
ul.nav-opts {
justify-content: flex-end;
}
.fake-nav {
height: 74px;
margin-bottom: 30px;
}
<section>
<div class="fake-nav"></div>
<header>
<nav>
<div class="container nav-content">
<div class="brand">
<img src="" alt="clickin logo">
</div>
<ul class="nav-opts">
<li>Home</li>
<li>Posts</li>
<li>Imagens</li>
</ul>
</div>
</nav>
</header>
<div class="container main">
<div class="form-background"></div>
<form>
<div class="edit-wrapper box">
<div class="edit left"> <label>Id do board <i class="fas fa-question"> <img class="img" src="" alt="Board Id?"> </i></label> <input name="board_id" type="number" required> </div>
<div class="edit right"> <label>Nome do Grupo<i class="fas fa-question"> <img class="img" src="" alt="Nome do Grupo?"> </i></label> <input name="group_name" type="text" required> </div>
</div>
<div class="edit middle box"> <label>Diretório da pasta para construção da estrutura<i class="fas fa-question"> <img class="img" src="" alt="Diretório desejado?"> </i></label> <input name="desired_path" type="text" required> </div>
<div class="edit-wrapper box">
<div class="edit left"> <label>Diretório dos Templates<i class="fas fa-question"> <img class="img" src="" alt="Diretório dos templates?"> </i></label> <input name="templates_path" type="text" required> </div>
<div class="edit right"> <label>Selecione os templates<i class="fas fa-question"> <img class="img" src=""> </i></label> <label class="input-file btn-anim" for="templates">Templates</label> <input name="templates" disabled id="templates" type="file" accept=".psd" multiple
required> </div>
</div>
<div class="edit-wrapper">
<div class="check-box" data-selected="false">
<div class="square"></div>
<span>Templates estruturados em ordem</span>
</div>
</div>
<div class="edit-wrapper mob">
<button type="button" class="refresh-options btn-anim"> Recarregar temas por possíveis mudanças <i class="fas fa-redo-alt"></i> </button>
<center> <img width="100px" class="loader" src="" alt="loading"> </center>
</div>
<div class="current-templates" style="display: block;">
<div class="file" selected_topics="">
<span class="template-name">Template 1</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 2</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 3</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
</div>
<div class="btn-wrapper"> <button class="btn-anim" type="submit">Gerar!</button> </div>
</form>
</div>
<footer>Copyright 2021 © João Webber</footer>
</section>
I think the offending part of your CSS code is this one:
.main.container {
flex-grow: 3;
height: auto;
padding: 0 50px;
overflow-y: scroll;
margin: 50px auto 50px auto;
display: flex;
align-items: center;
}
The margin: 50px auto 50px auto; forces your main.container to get squeezed in between your header and your footer, but the form is contains is not following his parent height.
Either:
you remove the overflow-y: scroll from .main.container to allow the <form> to increase the height of his parent, but no more scroll bar inside .main.container.
or you set <form> height: 100% to force him to take its parent height, which will still cause the scroll bar to appear in .main.container (because the form content can't be squeezed) but the top of your <form> will be aligned to the top of .main.container.
It's about 'display: flex;' a flexbox is not just one single property, it's a whole module. If your interested in reading a article about flexbox: guide to use flex-box.
When you delete the display: flex; in your main container it will solve your problem.
.form-background {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -999;
backdrop-filter: brightness(125%) hue-rotate(180deg) blur(10px);
background-color: rgba(0, 0, 0, .5)
}
/*
body {
background-image: url(https://images.pexels.com/photos/1624600/pexels-photo-1624600.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260)
}*/
section {
height: 100vh;
display: flex;
flex-direction: column;
overflow: auto!important
}
.container.main {
flex-grow: 3;
height: auto;
padding: 0 50px;
overflow-y: scroll;
margin: 50px auto 50px auto;
}
form {
width: 100%;
}
.edit {
width: 50%;
display: inline-block
}
.edit .input-file {
cursor: pointer
}
.edit.middle,
.edit.middle input {
width: 100%
}
.edit.custom-input {
width: 100%;
display: flex
}
.edit.right {
padding-left: 5px
}
.edit.left {
padding-right: 5px
}
.clickin {
margin: 15px 0
}
form>.box:nth-child(n+2) {
margin-top: 70px
}
.current-templates,
.mob {
display: none;
margin-top: 20px;
}
.current-templates .file {
padding: 10px;
font-size: 1.2rem
}
.current-templates .file:not(:first-child) {
margin-top: 20px
}
.current-templates .file,
.current-templates .options {
display: flex;
align-items: center
}
.current-templates .options {
width: 100%;
justify-content: space-around
}
.current-templates .file span {
white-space: nowrap
}
.current-templates .options {
margin-left: 30px;
list-style: none;
overflow: auto
}
.current-templates .options li {
padding: 4px 25px;
cursor: pointer;
white-space: nowrap;
text-align: center;
transition: background-color .2s var(--cubic-bezier)
}
.current-templates .options li:hover {
background-color: var(--hover-color)
}
.current-templates .options .opt[selected=true] {
background-color: rgba(18, 238, 102, .466)
}
.btn-wrapper {
width: 100%;
display: flex;
justify-content: center;
align-items: center
}
.btn-wrapper button {
padding: 10px;
font-size: 1.1rem;
cursor: pointer;
outline: 0;
border: solid #000 1px;
width: 200px;
margin-top: 30px
}
.btn-anim {
transition: background-color .2s var(--cubic-bezier), color .2s var(--cubic-bezier);
background-color: var(--input-color)
}
.btn-anim:hover {
background-color: var(--hover-color) !important;
color: #fff
}
.btn-anim-blocked:hover {
background-color: rgba(255, 110, 110, .363)!important;
color: #fff
}
.fas.fa-question {
font-size: .8rem;
margin-left: 15px;
cursor: pointer;
padding: 5px;
position: relative
}
.img {
position: absolute;
left: 100%;
top: 0;
visibility: hidden;
opacity: 0;
transform: translate(-50%, -150%);
transition: visibility .2s var(--cubic-bezier), opacity .2s var(--cubic-bezier), transform .2s var(--cubic-bezier)
}
button.refresh-options i {
background-color: transparent;
border: none;
border-radius: 100%;
padding: 5px 8px;
transition: transform 1s var(--cubic-bezier)
}
button.refresh-options {
background-color: transparent;
border: none;
padding: 8px;
font-size: 1rem;
cursor: pointer;
outline: 0;
display: none
}
.edit .input-file,
.edit input {
background-color: var(--input-color)
}
button.refresh-options:hover i {
transform: rotateZ(360deg)
}
.check-box {
margin: 15px 0 25px 1px;
display: flex;
align-items: center
}
.check-box .square {
position: relative;
width: 20px;
height: 20px;
background-color: transparent;
border: solid #fff 1px;
cursor: pointer
}
.check-box span {
margin-left: 20px
}
header {
position: fixed;
width: 100%;
background-color: transparent;
}
.container.nav-content {
padding: 0;
overflow: auto;
}
.container.nav-content {
grid-template-columns: auto 1fr;
justify-content: space-between;
}
ul.nav-opts {
justify-content: flex-end;
}
.fake-nav {
height: 74px;
margin-bottom: 30px;
}
<section>
<div class="fake-nav"></div>
<header>
<nav>
<div class="container nav-content">
<div class="brand">
<img src="" alt="clickin logo">
</div>
<ul class="nav-opts">
<li>Home</li>
<li>Posts</li>
<li>Imagens</li>
</ul>
</div>
</nav>
</header>
<div class="container main">
<div class="form-background"></div>
<form>
<div class="edit-wrapper box">
<div class="edit left"> <label>Id do board <i class="fas fa-question"> <img class="img" src="" alt="Board Id?"> </i></label> <input name="board_id" type="number" required> </div>
<div class="edit right"> <label>Nome do Grupo<i class="fas fa-question"> <img class="img" src="" alt="Nome do Grupo?"> </i></label> <input name="group_name" type="text" required> </div>
</div>
<div class="edit middle box"> <label>Diretório da pasta para construção da estrutura<i class="fas fa-question"> <img class="img" src="" alt="Diretório desejado?"> </i></label> <input name="desired_path" type="text" required> </div>
<div class="edit-wrapper box">
<div class="edit left"> <label>Diretório dos Templates<i class="fas fa-question"> <img class="img" src="" alt="Diretório dos templates?"> </i></label> <input name="templates_path" type="text" required> </div>
<div class="edit right"> <label>Selecione os templates<i class="fas fa-question"> <img class="img" src=""> </i></label> <label class="input-file btn-anim" for="templates">Templates</label> <input name="templates" disabled id="templates" type="file" accept=".psd" multiple
required> </div>
</div>
<div class="edit-wrapper">
<div class="check-box" data-selected="false">
<div class="square"></div>
<span>Templates estruturados em ordem</span>
</div>
</div>
<div class="edit-wrapper mob">
<button type="button" class="refresh-options btn-anim"> Recarregar temas por possíveis mudanças <i class="fas fa-redo-alt"></i> </button>
<center> <img width="100px" class="loader" src="" alt="loading"> </center>
</div>
<div class="current-templates" style="display: block;">
<div class="file" selected_topics="">
<span class="template-name">Template 1</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 2</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
<div class="file" selected_topics="">
<span class="template-name">Template 3</span>
<ul class="options">
<li class="opt" selected="false">1 °</li>
<li class="opt" selected="false">2 °</li>
<li class="opt" selected="false">3 °</li>
</ul>
</div>
</div>
<div class="btn-wrapper"> <button class="btn-anim" type="submit">Gerar!</button> </div>
</form>
</div>
<footer>Copyright 2021 © João Webber</footer>
</section>

hover Selector not working for this scenario? [duplicate]

This question already has answers here:
Is there a CSS parent selector?
(33 answers)
Is there a "previous sibling" selector?
(30 answers)
Closed 2 years ago.
This is for a Rock, Paper, Scissors game that I'm working on. I'm trying to make the sub-text slide in when you hover over the hands, but I can't seem to get it to work. What am I missing?
.choices {
display: flex;
flex-direction: column;
}
.hands {
height: 50%;
display: flex;
align-items: flex-end;
justify-content: space-evenly;
}
.far {
font-size: 5vh;
cursor: pointer;
}
.subText {
height: 50%;
display: flex;
justify-content: space-evenly;
}
#rock,
#paper,
#scissors {
opacity: 0;
height: 0;
background-color: rgb(100, 100, 100);
text-align: center;
margin-top: 0.5vh;
margin-left: 2vh;
font-size: 2vh;
transition: 0.3s;
}
.fa-hand-rock:hover+#rock {
opacity: 1;
height: 40%
}
.fa-hand-paper:hover+#paper {
opacity: 1;
height: 40%
}
.fa-hand-scissors:hover+#scissors {
opacity: 1;
height: 40%
}
<section class="choices">
<div class="hands">
<i class="far fa-hand-rock" onclick="game(1)"></i>
<i class="far fa-hand-paper" onclick="game(2)"></i>
<i class="far fa-hand-scissors" onclick="game(3)"></i>
</div>
<div class="subText">
<h6 id="rock">Rock</h6>
<h6 id="paper">Paper</h6>
<h6 id="scissors">Scissors</h6>
</div>
</section>
.hands{
padding:40px;
}
.choices {
display: flex;
flex-direction: column;
}
.far {
font-size: 20px;
cursor: pointer;
margin:0 50px;
}
.subText {
display: block;
}
#rock,
#paper,
#scissors {
opacity: 0;
background-color: rgb(100, 100, 100);
font-size: 12px;
transition: 0.3s;
display:inline-block;
text-align:center;
width:100px;
margin:10px 15px;
}
.fa-hand-rock:hover~.subText #rock {
opacity: 1;
}
.fa-hand-paper:hover~.subText #paper {
opacity: 1;
}
.fa-hand-scissors:hover~.subText #scissors {
opacity: 1;
}
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<section class="choices">
<div class="hands">
<i class="far fa-hand-rock" onclick="game(1)"></i>
<i class="far fa-hand-paper" onclick="game(2)"></i>
<i class="far fa-hand-scissors" onclick="game(3)"></i>
<div class="subText">
<h6 id="rock">Rock</h6>
<h6 id="paper">Paper</h6>
<h6 id="scissors">Scissors</h6>
</div>
</div>
</section>

How to make image of footer responsive to mobile devices?

In my project I have footer with image as background.
I set it inside css. You can see it below. It looks nice only in big screen devices but ugly in mobile screen. How to make image responsive?
I don't have much experience in frontend and I would like to know what are the options?
I use bootstrap 4 by the way.
Here the link to jsfiddle.
/*
* START: Footer
*/
footer {
background: url('http://enjoyjumping.kz/static/img//footer.png') no-repeat;
background-size: 100% 100%;
width: 100%;
height: 500px;
bottom: 0;
position: absolute;
}
footer .row {
align-items: flex-end;
}
.flex-container {
display: flex;
flex-direction: column;
}
.flex-container > div {
width: 100px;
margin: 10px;
text-align: center;
line-height: 75px;
font-size: 30px;
}
.social {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.social__button {
display: block;
width: 70px;
height: 70px;
border-radius: 100%;
border-color: #fff;
position: relative;
cursor: pointer;
margin: 5px;
text-align: center;
}
.social__button i {
display: inline-block;
position: absolute;
left: 0;
top: 0;
height: 70px;
line-height: 70px;
width: 70px;
font-size: 30px;
z-index: 2;
transition: 0.3s;
color: black;
border: 2px solid;
border-radius: 100%;
}
.social__button i:hover {
color: white;
}
.copyright {
margin-bottom: 2.1rem !important;
font-size: 18px;
font-weight: bold;
}
.menu-link {
color: black !important;
font-weight: bold;
}
.menu-link-li {
margin: 10px;
}
.footer-menu {
margin-bottom: 0.7rem !important;
}
/*
* END: Footer
*/
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<footer>
<div class="container-fluid h-100">
<div class="row h-100">
<div class="col-sm text-center footer-menu">
<ul class="list-unstyled">
<li class="menu-link-li">
<a class="menu-link no-underline text-uppercase" href="/about/">About Us</a>
</li>
<li class="menu-link-li">
<a class="menu-link no-underline text-uppercase" data-toggle="modal" data-target="#citiesModel" style="cursor: pointer;">Our clubs</a>
</li>
<li class="menu-link-li">
<a class="menu-link no-underline text-uppercase" href="/coaches/">News</a>
</li>
<li class="menu-link-li">
<a class="menu-link no-underline text-uppercase" href="/bonus/">Events</a>
</li>
</ul>
</div>
<div class="col-sm text-center">
<div class="flex-container">
<div class="w-100">
<div class="social">
<a href="#" class="social__button facebook">
<i class="fa fa-facebook"></i>
</a>
<a href="#" class="social__button instagram">
<i class="fa fa-instagram"></i>
</a>
<a href="#" class="social__button vk">
<i class="fa fa-vk"></i>
</a>
<a href="#" class="social__button youtube">
<i class="fa fa-youtube-play"></i>
</a>
</div>
</div>
<div class="w-100">
<span>+7(701)</span><strong>262-47-50</strong>
</div>
</div>
</div>
<div class="col-sm text-center">
<p class="copyright">Copyright © 2018 example.com</p>
</div>
</div>
</div>
</footer>
You need to change the background-size and background-position attributes of <footer>:
footer {
background: url('http://enjoyjumping.kz/static/img/footer.png') no-repeat top center /cover;
}
See it working: https://jsfiddle.net/7mejchb8/11/
Edit, based on comments: See this example on how to keep footer glued to the bottom of the page on all devices, while allowing it to have a variable height, without using position:absolute: https://jsfiddle.net/websiter/d4n1sxop/
CSS behind it is:
body {
min-height: 100vh;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
}
header {
flex-grow: 0;
}
main {
flex-grow: 1;
}
footer {
flex-grow: 0;
display: flex;
flex-direction: column;
justify-content: flex-end;
min-height: 500px;
}

Bootstrap- elements overlap on extra small size

I have recent-posts div that show two post with their images and text. after recent-posts I have another div contact-us that contain an image and some text. My issue appear in extra-small size where recent-posts posts go under contact-us part. How can I fix that? The following is my codes and JsFiddle.
HTML:
<div id="recent-posts" class="center-block row">
<div class="posts col-md-3 col-sm-5 col-xs-9">
<div class="posts-div">
<div class="img-hover">
<img src="images/post1.jpg" class="img-responsive">
<div class="overlay col-md-12 col-xs-12">
<div>
<span class="fa fa-2x fa-square post-icon" ><span class="fa fa-heart"></span></span>
<span class="fa fa-2x fa-square post-icon" ><span>16</span></span>
</div>
<div>
<span class="fa fa-2x fa-square post-icon" ><span class="fa fa-eye"></span></span>
<span class="fa fa-2x fa-square post-icon" ><span>16</span></span>
</div>
</div>
</div>
<p class="text-center">dsfdsfsdfldshfdskfhdsf</div>
</div>
<div class="posts col-md-3 col-sm-5 col-xs-9">
<div class="posts-div">
<div class="img-hover">
<img src="images/post2.jpg" class="img-responsive">
<div class="overlay col-md-12 col-xs-12">
<div>
<span class="fa fa-2x fa-square post-icon" ><span class="fa fa-heart "></span></span>
<span class="fa fa-2x fa-square post-icon" ><span>16</span></span>
</div>
<div>
<span class="fa fa-2x fa-square post-icon" ><span class="fa fa-eye "></span></span>
<span class="fa fa-2x fa-square post-icon" ><span>16</span></span>
</div>
</div>
</div>
<p class="text-center">dsjkfhjdssafjsdkjhfdsf</p>
</div>
</div>
</div>
<div id="contact-us" class="row">
<div class="col-md-12 col-xs-12">
<img src="http://www.infocurse.com/wp-content/uploads/2014/11/716988156_1368083660.png" class="img-responsive">
<div id="contact-us-text">
<p>sdkf,sd,kfnds,nf,d.....</p>
<p>kdsfnks,dnf,ksdnf,kdsnf,kdsnf,d</p>
<button class="btn btn-success pull-left">124234234</button>
</div>
</div>
</div>
Css:
#recent-posts{
height: 350px;
display: flex;
justify-content: center;
position: relative;
flex-wrap: wrap;
margin-bottom: 100px;
}
.posts{
display: flex;
flex-direction: column;
height: 350px;
margin-top: 20px;
position: relative;
border-radius: 5px;
box-shadow: 1px 1px 5px #888888;
padding: 0;
margin-left: 20px;
margin-right: 20px;
}
.posts img{
border-radius: 5px 5px 0 0;
cursor: pointer;
}
.posts .btn-success{
position: absolute;
background-color: #01a89e;
width: 50%;
color: #101010;
cursor: auto;
margin-top: -17px;
margin-right: 25%;
}
.posts .btn-success:active{
background-color: #01a89e;
color: #101010;
box-shadow: none;
}
.posts p{
margin-top: 30px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.overlay {
position: absolute;
top: 0;
bottom: 100%;
left: 0;
right: 0;
background-color: rgba(46, 183, 175, .7);
overflow: hidden;
height:0;
transition: .8s ease;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border-radius: 5px 5px 0 0;
}
.overlay div:first-child{
margin-left: 15px;
}
.posts-div:hover .overlay {
bottom: 0;
top: 0;
height: auto;
overflow: hidden;
}
.img-hover{
position: relative;
}
.post-icon{
color: rgba(255, 255, 255, 1);
transform: rotate(45deg);
opacity: 1;
}
.post-icon span{
transform: rotate(-45deg);
font-size: 12px;
position: absolute;
left: 50%;
top: 0.6em;
margin-left: -7px;
color: #101010;
font-weight: bold;
}
.fa-heart{
color: red !important;
}
#contact-us{
height: 200px;
margin-bottom: 30px;
box-shadow: 0 1px 5px #666666, 0 -1px 5px #666666;
position: relative;
padding: 0;
overflow: hidden;
}
#contact-us-text{
position: absolute;
top: 20%;
left: 12%;
}
#contact-us-text p{
color: white;
}
#contact-us-text .btn-success{
background-color: #01a89e;
cursor: auto;
}
#contact-us-text .btn-success:active{
background-color: #01a89e;
box-shadow: none;
}
JsFiddle
Recent-posts class has a fixed height.
#recent-posts{
height: 350px; // THIS LINE IS THE REASON!
display: flex;
justify-content: center;
position: relative;
flex-wrap: wrap;
margin-bottom: 100px;
}
Updated fiddle