Fixed Left Menu scrolling not working? - css

I have made following demo on Codepen. Problem is when the height of viewport is decreased scroll appear which i want but logo is hidden under icon-list which is the unwanted behavior. Everything works properly if viewport height is enough.
<input type="checkbox" id="menu-expander" name="ert">
<div class="main-menu-container">
<div class="logo-area">
<div class="logo"><img src="http://extensiondl.maxthon.com/skinpack/11018970/1375652328/icons/icon_32.png"></div>
</div>
<ul class="sidebar-icon-list">
<li class="sidebar-icon">
<img src="http://www.clipartsfree.net/vector/small/go-home_Clipart_Free.png">
<span>Week</span>
</li>
<li class="sidebar-icon menu-active">
<img src="http://www.clipartsfree.net/vector/small/go-home_Clipart_Free.png">
<span>Projects</span>
</li>
<li class="sidebar-icon" title="Life">
<img src="http://www.clipartsfree.net/vector/small/go-home_Clipart_Free.png">
<span>Life</span>
</li>
<li class="sidebar-icon">
<img src="http://www.clipartsfree.net/vector/small/go-home_Clipart_Free.png">
<span>Analysis</span>
</li>
<li class="sidebar-icon">
<img src="http://www.clipartsfree.net/vector/small/go-home_Clipart_Free.png">
<span>Projects</span>
</li>
</ul>
<div class="sidebar-wt">
<label for="menu-expander"><img src="https://cdn3.iconfinder.com/data/icons/awesome-lineca-vol-1/17/angle-right-128.png"></label>
</div>
<div class="user-area">
<div class="user-pic"></div>
</div>
CSS
input[name="ert"] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
overflow: hidden;
}
/* Main Menu Contaier */
.main-menu-container {
width: 6em;
position: fixed;
top: 0;
left: 0;
height: 100vh;
background-color: hsl(207,6%,12%);
color: #fff;
display: flex;
flex-direction: column;
z-index: 100;
border-right: 1px solid black;
transition: width 0.2s ease-in;
overflow-y: auto;
overflow-x: hidden;
}
input[name="ert"]:checked + .main-menu-container {
width: 12em;
transition: width .3s linear;
}
/* Logo Area */
.logo-area {
height: 6em;
background-color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 4em;
width: 4em;
}
.logo img {
height: 4em;
width: 4em;
}
/* Icon List */
.sidebar-icon-list {
display: flex column;
list-style: none;
width: 100%;
padding: 0;
margin: 0;
flex-grow: 1;
}
.sidebar-icon {
color: #eaeaea;
width: 100%;
border-left: 3px solid hsl(207,6%,12%);
height: 3em;
margin: 1em 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
cursor: pointer;
position: relative;
transition: all 0.3s linear;
}
.sidebar-icon:hover {
color: #fff;
border-left: 3px solid #EEFF22;
}
.sidebar-icon img {
color: #fff;
width: 2em;
height: 2em;
}
.sidebar-icon span {
font-size: 0.75em;
opacity: 0;
position: absolute;
transition: all 0.1s linear;
}
input[name="ert"]:checked + .main-menu-container .sidebar-icon-list .sidebar-icon {
flex-direction: row;
justify-content: flex-start;
padding-left: 1em;
transition: all 0.3s linear;
}
input[name="ert"]:checked + .main-menu-container .sidebar-icon-list .sidebar-icon span {
font-size: 0.75em;
opacity: 1;
position: relative;
transition: all 0.3s linear;
margin-left: 1em;
}
.menu-active {
border-left: 3px solid #EEFF22;
color: #EEFF22;
}
/* Sidebar Expander */
.sidebar-wt {
display: flex;
justify-content: flex-end;
}
.sidebar-wt label img {
height: 1.5em;
width: 1.5em;
cursor: pointer;
}
.main-menu-container .sidebar-wt label img {
transition: all 0.3s linear;
}
input[name="ert"]:checked + .main-menu-container .sidebar-wt label img {
transform: rotateZ(180deg);
transition: all 0.3s linear;
}
/* USer Area at Bottom */
.user-area {
height: 4em;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
}
.user-pic {
width: 100%;
height: 5em;
border-bottom: 2px solid #2ca58d;
background-image: url(http://soccer1x2.net/wp-content/uploads/2012/03/leo-messi1.png);
background-size: cover;
}
.main-menu-container .sidebar-wt label img {
transition: all 0.3s linear;
}
input[name="ert"]:checked + .main-menu-container .sidebar-wt label img {
transform: rotateZ(180deg);
transition: all 0.3s linear;
}

It looks like the height of .logo-container is changing, when you decrease the window's height.
If you min-height: 6em; for .logo-area the height will not decrease.

Related

Why isn't smooth snap scrolling working with my nav links?

Smooth snap scrolling works in every regard except when the nav links are used. Btw enabling smooth scrolling in Chrome didn't help and it's not working in other browsers anyway so there's something I'm not getting.
Here's my Codepen in case you don't want to deal with the provided code: https://codepen.io/CyberGolem/pen/RwLGJeQ
Many thanks in advance...
const section = document.querySelector(".container__section");
const sections = document.querySelectorAll(".container__section");
const clrBG = ["#dbf8c3", "#d8b0dd", "#9b9bdb", "#fff1c5", "#a9ecf8"];
const options = {
threshold: 0.5,
// rootMargin: "-100px",
};
const observer = new IntersectionObserver(function (entries, observer) {
entries.forEach((entry) => {
if (!entry.isIntersecting) {
return;
}
console.log(entry.target);
// observer.unobserve(entry.target);
});
}, options);
sections.forEach((section) => {
observer.observe(section);
});
*,
*::before,
*::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
text-decoration: none;
scroll-behavior: smooth;
overflow-y: scroll;
}
::-webkit-scrollbar {
display: none;
}
:root {
--nav-width: 10vw;
}
body {
color: #000;
background-color: whitesmoke;
font-family: "montserrat", sans-serif;
font-weight: 400;
width: 100vw;
height: 100vh;
margin: 0;
-webkit-transition: background-color 1s ease;
transition: background-color 1s ease;
}
.site-logo {
font-weight: 900;
font-size: 3rem;
color: var(--text);
text-decoration: none;
border: 1px solid red;
}
header {
--text: black;
--text-inverse: #333;
--background: transparent;
position: fixed;
top: 0;
left: 0;
height: 100vh;
width: var(--nav-width);
z-index: 999;
padding: 2em 3em;
-webkit-transition: background 250ms ease-in;
transition: background 250ms ease-in;
background: var(--background);
color: var(--text);
border: 3px solid blue;
}
.nav-bar {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-flow: column nowrap;
flex-flow: column nowrap;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
}
.nav-bar .nav__list {
list-style: none;
margin: 0;
padding: 0;
background: lightblue;
}
.nav-bar .nav__link {
--spacing: 1em;
margin-top: 10px;
text-decoration: none;
color: inherit;
display: inline-block;
padding: calc(var(--spacing) / 2) var(--spacing);
position: relative;
letter-spacing: 2px;
font-size: 0.9rem;
}
.nav-bar .nav__link:after {
content: "";
position: absolute;
bottom: 0;
left: var(--spacing);
right: var(--spacing);
height: 2px;
background: currentColor;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: -webkit-transform 150ms ease-in-out;
transition: -webkit-transform 150ms ease-in-out;
transition: transform 150ms ease-in-out;
transition: transform 150ms ease-in-out, -webkit-transform 150ms ease-in-out;
}
.nav-bar .nav__link:hover::after {
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.nav-bar .nav__link--btn {
border: 1.5px solid currentColor;
border-radius: 2em;
margin-left: 1em;
-webkit-transition: background 250ms ease-in-out;
transition: background 250ms ease-in-out;
letter-spacing: 1px;
padding: 0.75em 1.5em;
}
.nav-bar .nav__link--btn:hover {
background: var(--text);
color: var(--text-inverse);
border-color: var(--text);
}
.nav-bar .nav__link--btn::after {
display: none;
}
.nav-bar .nav__link--btn--highlight {
background: limegreen;
border-color: limegreen;
color: #333;
}
.nav-bar .nav__link--btn--highlight:hover {
background: var(--text);
border-color: var(--text);
}
.nav-scrolled {
--text: #333;
--text-inverse: #f4f4f4;
--background: #f4f4f4;
-webkit-box-shadow: 0 3px 20px rgba(0, 0, 0, 0.2);
box-shadow: 0 3px 20px rgba(0, 0, 0, 0.2);
}
.container {
width: 100%;
height: 100%;
-ms-scroll-snap-type: y mandatory;
scroll-snap-type: y mandatory;
overflow-y: scroll;
}
.container__section {
height: 100vh;
width: 100vw;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
scroll-snap-align: start;
font-family: "Rubik", sans-serif;
}
.container #sec0 {
color: slategrey;
}
.container #sec1 {
color: red;
}
.container #sec2 {
color: blue;
}
.container #sec3 {
color: green;
}
.container h2 {
font-size: 23rem;
}
/*# sourceMappingURL=main.css.map */
<body>
<header>
<div class="nav-bar">
<a href="#sec0"
class="site-logo"
aria-label="homepage">HOME</a>
<nav>
<ul class="nav__list">
<li class="nav__list--item">
<a href="#sec1"
class="nav__link">SEC 1</a>
</li>
<li class="nav__list--item">
<a href="#sec2"
class="nav__link">SEC 2</a>
</li>
<li class="nav__list--item">
<a href="#sec3"
class="nav__link">SEC 3</a>
</li>
</ul>
</div>
</nav>
</header>
<main class="container">
<section class="container__section"
id="sec0">
<h2>HOME</h2>
</section>
<section class="container__section"
id="sec1">
<h2>ONE</h2>
</section>
<section class="container__section"
id="sec2">
<h2>TWO</h2>
</section>
<section class="container__section"
id="sec3">
<h2>THREE</h2>
</section>
</main>
</body>

Unexpected space between spans

I built this button with transform and transition. But there is a tiny problem that I can't figure it out. I have for span to scale them when I want to hover the link. Each span have 25% of a link width. but there is a tiny space between span number 3 and 4.
codepen link
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: sans-serif;
}
a {
font-size: 25px;
font-weight: 700;
display: block;
text-decoration: none;
border: 3px solid rgb(84, 7, 136);
color: rgb(84, 7, 136);
padding: 50px 80px;
position: relative;
overflow: hidden;
}
h2 {
text-align: center;
}
body > div {
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.effect11 a span {
position: absolute;
top: 0;
left: 0;
width: 25%;
height: 100%;
background-color: black;
transform: scaleY(0);
transform-origin: top;
transition: all 1s;
z-index: -1;
}
.effect11 a {
transition: all 1s;
}
.effect11 a span:nth-child(1) {
left: 0;
transition-delay: 0.15s;
}
.effect11 a span:nth-child(2) {
left: 25%;
transition-delay: 0.3s;
}
.effect11 a span:nth-child(3) {
left: 50%;
transition-delay: 0.45s;
}
.effect11 a span:nth-child(4) {
left: 75%;
transition-delay: 0.6s;
}
.effect11 a:hover span {
transform: scaleY(1);
}
.effect11 a:hover {
color: white;
}
This is what happening that I don't want to appear (that little space)
Here add flex:1 and It should solve the problem
body > div {
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex:1;
}

Closing pure CSS Hamburger menu on click

I added code to hamburger menu below. I want to close menu after click on specific section.
For example, if you click on 'contact' section menu should hide and move me to contact section on page. I waste about one hour and really don't have an idea how to fix it, menu still appears on screen.
/* CORE STYLES */
:root {
--primary-color: rgba(13, 110, 139, 0.75);
--overlay-color: rgba(24, 39, 51 , 0.85);
--menu-speed: 0.75s;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
line-height: 1.4;
}
.container {
max-width: 960px;
margin: auto;
overflow: hidden;
padding: 0 3rem;
}
.showcase {
background: var(--primary-color);
color: #fff;
height: 100vh;
position: relative;
}
.showcase:before {
content: '';
background: url('https://images.pexels.com/photos/533923/pexels-photo-533923.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260') no-repeat center center/cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.showcase .showcase-inner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 100%;
}
.showcase h1 {
font-size: 4rem;
}
.showcase p {
font-size: 1.3rem;
}
.btn {
display: inline-block;
border: none;
background: var(--primary-color);
color: #fff;
padding: 0.75rem 1.5rem;
margin-top: 1rem;
transition: opacity 1s ease-in-out;
text-decoration: none;
}
.btn:hover {
opacity: 0.7;
}
/* MENU STYLES */
.menu-wrap {
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
.menu-wrap .toggler {
position: absolute;
top: 0;
left: 0;
z-index: 2;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0;
}
.menu-wrap .hamburger {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 60px;
height: 60px;
padding: 1rem;
background: var(--primary-color);
display: flex;
align-items: center;
justify-content: center;
}
/* Hamburger Line */
.menu-wrap .hamburger > div {
position: relative;
flex: none;
width: 100%;
height: 2px;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.4s ease;
}
/* Hamburger Lines - Top & Bottom */
.menu-wrap .hamburger > div::before,
.menu-wrap .hamburger > div::after {
content: '';
position: absolute;
z-index: 1;
top: -10px;
width: 100%;
height: 2px;
background: inherit;
}
/* Moves Line Down */
.menu-wrap .hamburger > div::after {
top: 10px;
}
/* Toggler Animation */
.menu-wrap .toggler:checked + .hamburger > div {
transform: rotate(135deg);
}
/* Turns Lines Into X */
.menu-wrap .toggler:checked + .hamburger > div:before,
.menu-wrap .toggler:checked + .hamburger > div:after {
top: 0;
transform: rotate(90deg);
}
/* Rotate On Hover When Checked */
.menu-wrap .toggler:checked:hover + .hamburger > div {
transform: rotate(225deg);
}
/* Show Menu */
.menu-wrap .toggler:checked ~ .menu {
visibility: visible;
}
.menu-wrap .toggler:checked ~ .menu > div {
transform: scale(1);
transition-duration: var(--menu-speed);
}
.menu-wrap .toggler:checked ~ .menu > div > div {
opacity: 1;
transition: opacity 0.4s ease 0.4s;
}
.menu-wrap .menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
visibility: hidden;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.menu-wrap .menu > div {
background: var(--overlay-color);
border-radius: 50%;
width: 200vw;
height: 200vw;
display: flex;
flex: none;
align-items: center;
justify-content: center;
transform: scale(0);
transition: all 0.4s ease;
}
.menu-wrap .menu > div > div {
text-align: center;
max-width: 90vw;
max-height: 100vh;
opacity: 0;
transition: opacity 0.4s ease;
}
.menu-wrap .menu > div > div > ul > li {
list-style: none;
color: #fff;
font-size: 1.5rem;
padding: 1rem;
}
.menu-wrap .menu > div > div > ul > li > a {
color: inherit;
text-decoration: none;
transition: color 0.4s ease;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/menu.css">
<title>Hamburger Menu Overlay</title>
</head>
<body>
<div class="menu-wrap">
<input type="checkbox" class="toggler">
<div class="hamburger"><div></div></div>
<div class="menu">
<div>
<div>
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div>
<header class="showcase">
<div class="container showcase-inner">
<h1>Welcome</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptas maiores sint impedit delectus quam molestiae explicabo cum facere ratione veritatis.</p>
Read More
</div>
</header>
</body>
</html>
Instead using a :checked input which is an issue if you want to unchecked it while you click on a link (make a choice click the input or the link) , you may use :focus that can easily be lost clicking anywhere else.
Possible example
/* CORE STYLES */
:root {
--primary-color: rgba(13, 110, 139, 0.75);
--overlay-color: rgba(24, 39, 51, 0.85);
--menu-speed: 0.75s;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Roboto", sans-serif;
line-height: 1.4;
}
.container {
max-width: 960px;
margin: auto;
overflow: hidden;
padding: 0 3rem;
}
.showcase {
background: var(--primary-color);
color: #fff;
height: 100vh;
position: relative;
}
.showcase:before {
content: "";
background: url("https://images.pexels.com/photos/533923/pexels-photo-533923.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260") no-repeat center center/cover;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.showcase .showcase-inner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 100%;
}
.showcase h1 {
font-size: 4rem;
}
.showcase p {
font-size: 1.3rem;
}
.btn {
display: inline-block;
border: none;
background: var(--primary-color);
color: #fff;
padding: 0.75rem 1.5rem;
margin-top: 1rem;
transition: opacity 1s ease-in-out;
text-decoration: none;
}
.btn:hover {
opacity: 0.7;
}
/* MENU STYLES */
.menu-wrap {
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
.menu-wrap .toggler {
position: absolute;
top: 0;
left: 0;
z-index: 2;
cursor: pointer;
width: 50px;
height: 50px;
opacity: 0;
}
.menu-wrap .hamburger {
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 60px;
height: 60px;
padding: 1rem;
background: var(--primary-color);
display: flex;
align-items: center;
justify-content: center;
}
/* Hamburger Line */
.menu-wrap .hamburger>div {
position: relative;
flex: none;
width: 100%;
height: 2px;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.4s 0.4s ease;
}
/* Hamburger Lines - Top & Bottom */
.menu-wrap .hamburger>div::before,
.menu-wrap .hamburger>div::after {
content: "";
position: absolute;
z-index: 1;
top: -10px;
width: 100%;
height: 2px;
background: inherit;
}
/* Moves Line Down */
.menu-wrap .hamburger>div::after {
top: 10px;
}
/* Toggler Animation */
.menu-wrap .hamburger:focus>div {
transform: rotate(135deg);
}
/* Turns Lines Into X */
.menu-wrap .hamburger:focus>div:before,
.menu-wrap .hamburger:focus>div:after {
top: 0;
transform: rotate(90deg);
}
/* Rotate On Hover When Checked */
.menu-wrap .hamburger:focus>div {
transform: rotate(225deg);
}
/* Show Menu */
.menu-wrap .hamburger:focus~.menu {
visibility: visible;
}
.menu-wrap .hamburger:focus~.menu>div {
transform: scale(1);
transition-duration: var(--menu-speed);
}
.menu-wrap .hamburger:focus~.menu>div>div {
opacity: 1;
transition: opacity 0.4s ease 0.4s;
}
.menu-wrap .menu {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
visibility: hidden;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.menu-wrap .menu>div {
background: var(--overlay-color);
border-radius: 50%;
width: 200vw;
height: 200vw;
display: flex;
flex: none;
align-items: center;
justify-content: center;
transform: scale(0);
transition: all 0.4s ease;
}
.menu-wrap .menu>div>div {
text-align: center;
max-width: 90vw;
max-height: 100vh;
opacity: 0;
transition: opacity 0.4s ease;
}
.menu-wrap .menu>div>div>ul>li {
list-style: none;
color: #fff;
font-size: 1.5rem;
padding: 1rem;
}
.menu-wrap .menu>div>div>ul>li>a {
color: inherit;
text-decoration: none;
transition: color 0.4s ease;
}
/* whatever only for the demo */
div.boxe {
height: 100vh;
width: 100vw;
position: fixed;
top: 100vh;
left: 0;
transition: 0.5s;
z-index: 10;
display:flex;
align-items:center;
justify-content:space-around;
font-size: 5vmax
}
div.boxe:target {
top: 0;
background: rgba(13, 110, 139, 1);
}
<div class="menu-wrap">
<!--<input type="checkbox" class="toggler"> removed for a tabindex attribute -->
<div tabindex="0" class="hamburger">
<!-- give it a tabindex to make it clikable and be focused -->
<div></div>
</div>
<div class="menu">
<div>
<div>
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div>
<header class="showcase">
<div class="container showcase-inner">
<h1>Welcome</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptas maiores sint impedit delectus quam molestiae explicabo cum facere ratione veritatis.</p>
Read More
</div>
</header>
<!-- whatever, just for a demo -->
<div id="aa" class="boxe">topbox A</div>
<div id="bb" class="boxe">topbox B</div>
<div id="cc" class="boxe">topbox C</div>
<div id="dd" class="boxe">topbox D</div>

Max-height no respecting css transistion

I'm trying to create a CSS transistion where When I click on a button it fades out and disappears to which another element will take it's place.
I've nearly completed it, however. When applying the class .hide to the button it "jumps" (the height property is not to be touched until the opacity is done). The max-height does not seem to respect the css transition property I've set in the css.
Codepen: https://codepen.io/basickarl/pen/zwzNXM?editors=1111
HTML:
<div class="app-profession">
<button id="one" class="add-profession" onclick="func()">
<img/>
Click me!
</button>
<div id="two" key="pickArea" class="pick-area">
Here! 2
</div>
</div>
SCSS:
button.add-profession {
width: 500px;
padding-top: 16px;
padding-bottom: 16px;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Verdana';
font-size: 18px;
font-weight: 300;
text-decoration: none;
color: black;
outline-style: none;
border: none;
border-radius: em(0);
opacity: 1;
background: lightblue;
img {
margin-right: em(5);
content: url('static/images/add_cross_white.png');
height: em(30);
}
transition: opacity 2s ease-in-out 0s, max-height 0s linear 2s, padding 0s ease-in-out 2s;
&.hide {
opacity: 0;
max-height: 0; // <--- here
padding: 0;
overflow: hidden;
}
&:hover {
background-color: red;
cursor: pointer;
}
}
.pick-area {
display: flex;
justify-content: center;
align-items: center;
background-color: green;
opacity: 0;
max-height: 0em;
overflow: hidden;
width: 500px;
padding: 16px;
transition: all 2s linear 2s;
&.show {
max-height: 500px;
opacity: 1;
}
}
JS:
function func() {
document.getElementById('one').classList.add('hide');
document.getElementById('two').classList.add('show');
}
If you add a max-height to the button.add-profession class it will stop jumping
button.add-profession {
width: 500px;
padding-top: 16px;
padding-bottom: 16px;
max-height: 60px; /* added property */
....
Updated codepen

transition width not working?

I have this HTML:
.orderData_button {
background-color: #FF5733;
border: none;
color: white;
padding: 5px 60px;
text-align: center;
display: inline-block;
font-size: 16px;
transition: width 1s ease-in-out
}
.slideDown_orderData {
display: none;
position: relative;
z-index: 3;
transition: width 1s ease-in-out
}
.orderData_button:hover .slideDown_orderData {
display: block;
width: 100%;
}
.orderData_button:hover {
width: 50%;
}
#orderData_2 {
font-size: 20px;
text-align: center;
}
<div class="orderData_button">
<p>Your Orders</p>
<p></p>
<div class="slideDown_orderData">
<p id="orderData_2"></p>
</div>
</div>
My orderData_button and slideDown_orderData will not transition width, but will change instantly. Why is this? (Yes I have look all over google, with no success)
-CSS noob

Resources