Max-height no respecting css transistion - css

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

Related

How do I get my images to fit into my rows and columns of my bootstrap grid?

I have searched SO for this answer and could not find something specific enough that works. I saw there were a lot of similar questions, but none that lead me to a working solution. I am sorry if this is a duplicate
I am trying to replicate the feature elements from the MySpace homepage (https://myspace.com/). I am trying to get one main feature image on the left and two smaller elements (img and video) on the right. The images should go flush against each other with each column being the same height. The grid should be responsive to the changes in size of the web broser so it stays centered, proportionate, and flush.
I am using the Bootstrap 5 grid system. I have a container with a main row. That row contains two columns. The left column is for the main image. The right column holds two more rows. The top row has an image, the bottom row has an iframe.
I have used object-fit: cover, overflow:hidden, max-width: some value, max-height: auto (and vice-versa), and all combinations of rows/cols.
I've spent hours Googling and looking up examples and YouTube videos. Everything is showing basic concepts but nothing with examples in ReactJS or that are at my lower skill level.
This feels like it should be super easy and it has been the hardest thing I've had. I have even been staring at the HTML in the devtools of the MySpace page to see if I can reverse-engineer it.
import React from "react";
import Feature from "../page/Feature";
import { IMAGES_BANDS, VIDEOS_HIGHLIGHTS } from "../../images/images";
export default function Bands() {
return (
<>
<div className="container">
<div className="row">
<Feature
IMAGES_FEATURE={IMAGES_BANDS}
IMAGE_HIGHLIGHT={IMAGES_BANDS[0].image}
VIDEO_HIGHLIGHT={VIDEOS_HIGHLIGHTS[0].video}
/>
</div>
</div>
</>
);
}
import React from "react";
import Slider from "../page/Slider";
export default function Feature(props) {
const { IMAGES_FEATURE, IMAGE_HIGHLIGHT, VIDEO_HIGHLIGHT } = props;
return (
<>
<div className="container image-fit-cover no-margin-padding">
<div className="row row-cols-2 justify-content-center row-size-feature">
<div className="col-8">
<Slider images={IMAGES_FEATURE} />
</div>
<div className="col-4">
<div className="row">
<img src={IMAGE_HIGHLIGHT} alt="band-highlight" />
</div>
<div className="row">
<iframe
src={VIDEO_HIGHLIGHT}
title="YouTube video player"
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowFullScreen
/>
</div>
</div>
</div>
</div>
</>
);
}
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
#media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
#keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.colors-theme {
background-color: black !important;
color: white !important;
}
.btn-theme {
background-color: white;
color: #000000;
display: inline-block;
font-weight: 400;
text-align: center
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
text-decoration: none
}
.btn-theme:focus,
.btn-theme:hover {
text-decoration: none;
background-color: #944dff;
color: #e0ccff;
}
.btn-theme-dark {
color: white;
background-color: black;
display: inline-block;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out
}
.btn-theme-dark:focus,
.btn-theme-dark:hover {
text-decoration: none;
color: black;
background-color: #e0f2f1;
}
.btn-link-theme {
font-weight: 400;
color: #f0e6ff;
background-color: transparent;
border-color: transparent;
text-decoration: none;
padding: 0px;
}
.btn-link-theme:hover {
color: gray;
text-decoration: underline;
background-color: transparent;
border-color: transparent
}
.navbar-search-form {
justify-content: flex-end;
}
.float-right{
float: right;
}
/*slider css*/
.slider {
position: relative;
margin-top: 10px;
margin-bottom: 20px;
display: flex;
justify-content: center;
align-items: center;
}
. right-arrow {
position: absolute;
top: 50%;
right: 5px;
font-size: 1rem;
color: black;
z-index: 10;
cursor: pointer;
user-select: none;
}
.left-arrow {
position: absolute;
top: 50%;
left: 5px;
font-size: 1rem;
color: black;
z-index: 10;
cursor: pointer;
user-select: none;
}
.slide {
opacity: 0;
transition-duration: 2s ease;
}
.slide.active {
opacity: 1;
transition-duration: 2s;
transform: scale(1.00);
}
/**/
.text-overlay-parent {
position: relative;
width: 100%;
height: 100%;
}
.text-overlay-child{
position: absolute;
top: 15%;
left: 10%;
}
.font-styles-heading{
font-family:'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
.row-size-feature{
height: 360px;
}
.image-fit-cover img {
height:auto;
max-width:700px;
overflow: hidden;
object-fit: cover;
}
.image-fit-cover iframe {
height: auto;
max-width: 700px;
overflow: hidden;
object-fit: cover;
}
.no-margin-padding * {
margin: 0px;
padding: 0px;
}
img of current page

Transition not applying on hover CSS

I'm trying to get the "::after" content defined for the ".projectBtn" element upon hovering it, with a subtle transition. However, I've tried applying the
transition: all 1s linear;
to ".projectBtn::after" as well as ".projectBtn" but it still shows up suddenly.
Here is the code -
CSS -
.projectFooter {
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 0.5em;
}
.projectTech {
display: flex;
justify-content: flex-end;
transition: all 2s linear;
gap: 1em;
}
.projectBtn {
background-color: inherit;
transition: all 2s linear;
color: inherit;
}
.projectBtn:hover::after {
transition: all 2s linear;
content: " This project is made with the help of ReactJS.";
}
JSX -
<div className="projectFooter">
<div className="projectTech">
<button className="projectBtn">
<FaReact size={25} />
</button>
</div>
<div className="projectGithub">
<FiGithub size={18} />
</div>
</div>
Here is the screenshot of what it looks like.
This is because you are not using any transform properties on your ::after content.
Refer the code below. Hoping it might help you.
button {
outline: none;
border: none;
padding: .5rem;
font-family: 'Helvetica Neue';
font-size: 48px;
color: rgb(20, 20, 20);
position: relative;
background: none;
}
button::after {
content: 'This project is made using React';
font-size: 14px;
position: absolute;
left: 100%;
white-space: nowrap;
top: 50%;
opacity: 0;
transform: translateX(-30%) translateY(-50%);
transition: all .5s ease-in;
}
button:hover::after {
opacity: 1;
transform:translateX(10%) translateY(-50%);
}
<button>⚛</button>

CSS - Display text next to icon inside the button on the :hover effect

I am having a little problem with displaying the text inside the button on the :hover effect. I want to have an effect where user will hover of the button and the text appears.
I managed to make it work, but the text is to close to the icon itself, and when I add the margin I get bad proportion of the box.
Here is the code:
CSS
.favourite-btn {
position: absolute;
display: flex;
background-color: gray;
align-items: center;
justify-content: center;
cursor: pointer;
outline: none;
border: 0;
color: #fff;
transition: width 0.3s ease-in-out;
padding: 0.5rem;
}
.favourite-btn__text {
max-width: 0;
white-space: nowrap;
overflow: hidden;
color: white;
margin-left: 0.5rem;
transition: max-width 0.3s ease-in-out;
margin-left: 0.5rem;
}
.favourite-btn:hover .favourite-btn__text {
max-width: 15rem;
}
JSX
<button className="favourite-btn rounded-md">
<AiOutlineHeart className="text-2xl favourite-btn__icon" />
<span className="favourite-btn__text">Add to favourites</span>
</button>
I am also using TailwindCSS but that is not important in this case I think. What can I do to fix this?
If you want to test the button I made a sandbox for it. Here you go: https://codesandbox.io/s/spring-forest-k5cr50?file=/src/App.js
.favourite-btn {
position: absolute;
display: flex;
background-color: gray;
align-items: center;
justify-content: center;
cursor: pointer;
outline: none;
border: 0;
color: #fff;
transition: width 0.3s ease-in-out;
padding: 0.5rem;
}
.favourite-btn__text {
max-width: 0;
white-space: nowrap;
overflow: hidden;
color: white;
//margin-left: 0.5rem // remove this line
transition: max-width 0.3s ease-in-out;
transition: margin-left 0.3s ease-in-out; // also add animation to margin
}
.favourite-btn:hover .favourite-btn__text {
margin-left: 0.5rem; // add margin to the text on hover
max-width: 15rem;
}

Fixed Left Menu scrolling not working?

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.

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