backface-visibility is working only partly - html

I'm trying to make a card that flipping on hover. To hide the back part of a card I use backface-visibility: hidden. But it only hides background of the back part while all the elements are still visible on the front side in rotated variant.
I use Google Chrome.
Here's my html code
<div class="card">
<div class="card__side card__side--front">
<div class="card__picture card__picture--1"></div>
<div class="card__heading">
<span class="card__heading-span card__heading-span--1">
The sea explorer
</span>
</div>
<div class="card__details">
<ul class="card__list">
<li class="card__item">3 day tour</li>
<li class="card__item">Up to 30 people</li>
<li class="card__item">2 tour guides</li>
<li class="card__item">Sleep in cozy hotels</li>
<li class="card__item">Difficulty: easy</li>
</ul>
</div>
</div>
<div class="card__side card__side--back card__side--back-1">
<div class="card__cta">
<div class="card__price-box">
<p class="card__price--only">Only</p>
<p class="card__price--value">$297</p>
</div>
Book now
</div>
</div>
</div>
And here's my SASS code
.card {
position: relative;
height: 52rem;
perspective: 150rem;
&__side {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 52rem;
border-radius: 3px;
overflow: hidden;
box-shadow: 0 1.5rem 4rem rgba($color-black, .15);
transform-style: preserve-3d;
backface-visibility: hidden;
transition: all .8s ease;
&--front {
background-color: $color-white;
}
&--back {
transform: rotateY(180deg);
&-1 {
background-image:
linear-gradient(to right bottom,$color-secondary-light,$color-secondary-dark);
}
&-2 {}
&-3 {}
}
}
&:hover &__side--front {
transform: rotateY(-180deg);
}
&:hover &__side--back {
transform: rotateY(0);
}
// Front side styles
&__picture {
&--1 {}
&--2 {}
&--3 {}
}
&__heading {
}
&__heading-span {
&--1 {}
&--2 {}
&--3 {}
}
&__details {
}
&__list {
width: 80%;
margin: 0 auto;
list-style-type: none;
}
&__item {
&:not(:last-child) {
border-bottom: 1px solid $color-gray-light-2;
}
}
//Back side styles
&__cta {
#include absoluteCenter();
width: 90%;
text-align: center;
}
&__price-box {
margin-bottom: 6rem;
color: $color-black;
text-align: center;
}
&__price--only {
font-size: 1.4rem;
text-transform: uppercase;
}
&__price--value {
font-size: 6rem;
font-weight: 300;
}
}
And this is how the problem actually looks like in Chrome.

Adding transform-style: preserve-3d to .card instead of .card__side fixed the bug for me.

Related

How can I contain my text to stay inside the card without changing all my or html to much?

I do not want to use anything except css and html. What can be changed to fix the text from coming outside of the card? My text keeps overflowing outside of my card. I want it all to fit in without compromising the card size as well. I have tried resizing. I am also new to coding. I would accept all and any feedback. If you have links or videos please share those also.
* {
margin:0;
padding: 0;
}
body {
color: #fff;
-webkit-font-smoothing: antialiased;
font-size: 25px;
background-color: #b4b4b4;
}
/* Header Start */
#vanta-canvas {
width: 100vw;
height: 50vh;
}
.inner_header {
width: 100%;
height: 100%;
margin: 0 auto;
text-align: center;
position: relative;
top: 75px;
}
.flex {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
flex-wrap: nowrap;
align-content: normal;
}
header p {
color: #b4b4b4;
font-family: cursive;
-webkit-font-smoothing: antialiased;
font-size: 50px;
}
.highlight {
color: blue;
-webkit-font-smoothing: antialiased;
}
button {
background-color: transparent;
border-radius: 45% 3px;
color: #b4b4b4;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 20px;
cursor: pointer;
margin: 0 auto;
text-align: center;
position: relative;
top: 25px;
-webkit-font-smoothing: antialiased;
transition: all 0.3s;
}
button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.3s;
}
button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.3s;
}
button:hover, button:focus{
background-color: grey;
color: blue;
}
button:hover span {
padding-right: 25px;
}
button:hover span:after{
opacity: 1;
right: 0;
}
/* Header End */
/* navigation Start */
nav {
background: blue;
border-bottom: solid 2px;
border-bottom-color: white;
}
nav li {
display: inline-block;
margin-left: 30px;
}
nav a {
text-decoration: none;
color: #fff;
}
/* Navigation End */
/* Section About Start */
section {
box-align: center;
}
section h2 {
text-align: center;
margin-top: 100px;
/* border-bottom: solid 3px; */
color: black;
position: relative;
left: 50%;
transform: translateX(-50%)
}
section h2::after {
content:"";
height: 3px;
width: 70px;
position: absolute;
background: #000000;
margin: auto;
bottom: -5px;
left: 0;
right: 0;
}
section p {
padding: 20px;
text-align: center;
position: relative;
margin: auto;
}
/* Section About End */
/* Section Portfolio Start */
.flip-card {
background-color: transparent;
width: 300px;
height: 200px;
border: 1px solid #f1f1f1;
perspective: 1000px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card:hover .flip-card-inner{
transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backgrace-visibility: hidden;
backface-visibility: hidden;
}
.flip-card-back {
background-color: transparent;
color: white;
transform: rotateY(180deg);
}
/* #media screen and (max-width: 600px){ */
/* .column {
width: 100%;
display: block;
margin-bottom: 20px;
}
} */
<!DOCTYPE html>
<html lang="en_US">
<head>
<meta charset="UTF-8" />
<title>Portfolio</title>
<link rel="stylesheet" href="./assets/css/style.css" >
</head>
<body>
<!-- Header Start -->
<div id="vanta-canvas">
<header>
<h1 class="inner_header" class="flex" id="Home">
<p>
Hello, I'm
<span class="highlight">Brian Mojica.</span>
<br>
I'm a full-stack web developer.
<button class="flex" style="vertical-align:middle"><span>
View My Work
</span></button>
</p>
</h1>
</header>
</div>
</header>
<!--Header End-->
<!-- Navigation Start -->
<nav>
<ul>
<li>
HOME
</li>
<li>
ABOUT
</li>
<li>
PORTFOLIO
</li>
<li>
BLOG
</li>
<li>
CONTACT
</li>
<li>
RESUME
</li>
</ul>
</nav>
<!--Navigation End-->
<!--Section About-->
<section>
<h2 id="About">ABOUT</h2>
<p>
I'm a full stack developer seeking employment.
I have a passion developing webpages that are responsive, dynamic, and accessbile.
Animations and UI effects are skills I hope to sharpen. I will continually expand my knowledge in different platforms such as Python, JavaScript, and React.
</p>
</section>
<!--Section Portfolio-->
<section>
<h2 id="Portfolio">PORTFOLIO</h2>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="assets/images/run-buddy-card.png" alt="Webpage" style="width:100%" height="100%">
</div>
<div class="flip-card-back">
<h1>Run Buddy</h1>
<p class="highlight"> HTML / CSS</p>
<p>A webpage for Run Buddy. They are a company that matches runners with personal trainers. </p>
<button class="flex" style="vertical-align:middle"><span> View</span></button>
</div>
</div>
</div>
</section>
<!--Section Blog-->
<section>
<h2 id="Blog">BLOG</h2>
<p>Under Construction</p>
</section>
<!--Section Contact-->
<section>
<h2 id="Contact">CONTACT</h2>
</section>
<!--Section Resume-->
<section>
<a id="resume" href="https://drive.google.com/file/d/1uVWXW7AULRBQBeXEblFfHNawPX-pHrJC/view?usp=sharing"></a>
</section>
<!--script for header background Start-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta#latest/dist/vanta.waves.min.js"></script>
<script>
VANTA.WAVES({
el: "#vanta-canvas",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 100.00,
minWidth: 100.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x102
})
</script>
<!--script for header background End-->
</body>
</html>
You can use overflow: hidden or overflow: scroll properties in the .flip-card-back class to either hide the content that isn't fitting or make it scrollable. You should also keep in mind the size of the content, it's too much for the card's dimensions. Styling properly the text inside the card would be the best approach.
I changed your code. Please check. the important point is to use font-size: 6vmin in here for #vanta-canvas. I used that instead of h1. It causes a font-size based on screen size.
Note: https://css-tricks.com/viewport-sized-typography/
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
color: #fff;
-webkit-font-smoothing: antialiased;
font-size: 25px;
background-color: #b4b4b4;
}
/* Header Start */
#vanta-canvas {
width: 100%;
height: 50vh;
display: flex;
align-items: center;
border: solid;
font-weight: bold;
font-size: 6vmin; /* here */
}
.inner_header {
width: 100%;
margin: 0 auto;
text-align: center;
}
.flex {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
flex-wrap: nowrap;
align-content: normal;
}
.inner_header p {
color: #b4b4b4;
font-family: cursive;
-webkit-font-smoothing: antialiased;
}
.highlight {
color: blue;
-webkit-font-smoothing: antialiased;
}
button {
background-color: transparent;
border-radius: 45% 3px;
color: #b4b4b4;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
font-size: 20px;
cursor: pointer;
margin: 0 auto;
text-align: center;
position: relative;
top: 25px;
-webkit-font-smoothing: antialiased;
transition: all 0.3s;
}
button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.3s;
}
button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.3s;
}
button:hover,
button:focus {
background-color: grey;
color: blue;
}
button:hover span {
padding-right: 25px;
}
button:hover span:after {
opacity: 1;
right: 0;
}
/* Header End */
/* navigation Start */
nav {
background: blue;
border-bottom: solid 2px;
border-bottom-color: white;
}
nav li {
display: inline-block;
margin-left: 30px;
}
nav a {
text-decoration: none;
color: #fff;
}
/* Navigation End */
/* Section About Start */
section {
box-align: center;
}
section h2 {
text-align: center;
margin-top: 100px;
/* border-bottom: solid 3px; */
color: black;
position: relative;
left: 50%;
transform: translateX(-50%)
}
section h2::after {
content: "";
height: 3px;
width: 70px;
position: absolute;
background: #000000;
margin: auto;
bottom: -5px;
left: 0;
right: 0;
}
section p {
padding: 20px;
text-align: center;
position: relative;
margin: auto;
}
/* Section About End */
/* Section Portfolio Start */
.flip-card {
background-color: transparent;
width: 300px;
height: 200px;
border: 1px solid #f1f1f1;
perspective: 1000px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backgrace-visibility: hidden;
backface-visibility: hidden;
}
.flip-card-back {
background-color: transparent;
color: white;
transform: rotateY(180deg);
}
/* #media screen and (max-width: 600px){ */
/* .column {
width: 100%;
display: block;
margin-bottom: 20px;
}
} */
<!-- Header Start -->
<div id="vanta-canvas">
<div class="inner_header" class="flex" id="Home">
<p>
Hello, I'm
<span class="highlight">Brian Mojica.</span>
<br> I'm a full-stack web developer.
<button class="flex" style="vertical-align:middle"><span>
View My Work
</span></button>
</p>
</div>
</div>
</header>
<!--Header End-->
<!-- Navigation Start -->
<nav>
<ul>
<li>
HOME
</li>
<li>
ABOUT
</li>
<li>
PORTFOLIO
</li>
<li>
BLOG
</li>
<li>
CONTACT
</li>
<li>
RESUME
</li>
</ul>
</nav>
<!--Navigation End-->
<!--Section About-->
<section>
<h2 id="About">ABOUT</h2>
<p>
I'm a full stack developer seeking employment. I have a passion developing webpages that are responsive, dynamic, and accessbile. Animations and UI effects are skills I hope to sharpen. I will continually expand my knowledge in different platforms such
as Python, JavaScript, and React.
</p>
</section>
<!--Section Portfolio-->
<section>
<h2 id="Portfolio">PORTFOLIO</h2>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<img src="assets/images/run-buddy-card.png" alt="Webpage" style="width:100%" height="100%">
</div>
<div class="flip-card-back">
<h1>Run Buddy</h1>
<p class="highlight"> HTML / CSS</p>
<p>A webpage for Run Buddy. They are a company that matches runners with personal trainers. </p>
<button class="flex" style="vertical-align:middle"><span> View</span></button>
</div>
</div>
</div>
</section>
<!--Section Blog-->
<section>
<h2 id="Blog">BLOG</h2>
<p>Under Construction</p>
</section>
<!--Section Contact-->
<section>
<h2 id="Contact">CONTACT</h2>
</section>
<!--Section Resume-->
<section>
<a id="resume" href="https://drive.google.com/file/d/1uVWXW7AULRBQBeXEblFfHNawPX-pHrJC/view?usp=sharing"></a>
</section>
<!--script for header background Start-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta#latest/dist/vanta.waves.min.js"></script>
<script>
VANTA.WAVES({
el: "#vanta-canvas",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 100.00,
minWidth: 100.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x102
})
</script>
<!--script for header background End-->
On larger screen size:
On smaller screen size:

Adding classes to a parent div on click

I have a setup that works similarly to an accordion, but vertical. I would like the add the class "unset" to the "choice" class, also while removing the "expand" and "small" classes.
I've edited the jQuery code to include to say when the card-close class is clicked, choice removes expand and adds class unset, and also if card-close is clicked, choice removes small and adds class unset.
Nothing I have used though has worked and I'm thinking it's because the div is inside the "choice" section.
Any ideas on how to get this to work?
jQuery(document).ready(function() {
jQuery(".card-close").on("click", function() {
jQuery(".choice").removeClass("expand");
jQuery(".choice").addClass("unset");
jQuery(".choice").removeClass("small");
jQuery(".choice").addClass("unset");
});
jQuery(".choice").on("click", function() {
jQuery(".choice").removeClass("expand unset ");
jQuery(".choice").addClass("small");
jQuery(this).removeClass("small");
jQuery(this).addClass("expand");
});
})
.container {
display: flex;
width: 100%;
padding: 0;
}
.choice {
height: 40vw;
box-sizing: border-box;
padding: 0;
overflow: hidden;
float: left;
align-items: center;
transition: width 0.2s;
position: relative;
}
.card-body {
z-index: 9;
}
.card-body h4 {
text-align: center;
font-family: 'Poppins', sans-serif !important;
color: #fff;
font-weight: 700;
opacity: .7;
text-decoration: none;
text-transform: uppercase;
margin-bottom: 3px;
width: max-content;
}
.card-body .card-title {
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
text-align: center;
}
.expand .card-body .card-title {
left: 56%;
top: 40%;
}
.card-body .card-title .card-open,
.card-body .card-title .card-close {
color: #000;
background-color: #CBE3A9;
width: max-content;
padding: 0 7px;
font-size: 20px;
margin: 0 auto;
}
.card-body .card-title .card-close,
.expand .card-body .card-title .card-open {
display: none;
}
.expand .card-body .card-title .card-close,
.card-body .card-title .card-open {
display: block;
}
.choice .bg-image {
background-size: cover;
width: 100%;
height: 100%;
position: absolute;
filter: blur(6px);
transition: 1s;
z-index: -9;
}
.danger-color .bg-image {
background-color: green;
}
.warning-color .bg-image {
background-color: blue;
}
.success-color .bg-image {
background-color: red;
}
.info-color .bg-image {
background-color: yellow;
}
.choice.expand .bg-image {
filter: blur(0px);
transition: 1s;
z-index: -999;
}
.expand .card-text {
width: 32%;
background-color: #A7D16D;
padding: 2%;
margin: 0 auto;
position: absolute;
left: 57%;
top: 51.9%;
}
.expand .card-body h4 {
opacity: 1;
font-size: 65px;
}
.small .card-body h4 {
font-size: 25px;
}
.expand {
width: 130%;
}
.unset {
width: 25%;
cursor: pointer;
}
.small .card-title h4 {
display: none;
}
.small {
width: 5%;
cursor: pointer;
background-color: #0000006e;
}
.small>.card-body .card-text {
opacity: 0;
}
.unset>div>p {
opacity: 0;
}
.expand>div {
transition-delay: 200ms;
opacity: 1;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div class="container mt-5 justify-content-center">
<div class="choice unset mx-2 danger-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Strategic</h4>
<p class="card-open">+</p>
<p class="card-close">-</p>
</div>
<!-- Text -->
<p class="card-text">Every FeltonBuford Partners’ insight strategist has worked on the client side. As former leaders of businesses, we can understand the problems our clients face and deliver the level of strategic thinking that leads to true business breakthroughs.</p>
</div>
</div>
<div class="choice unset mx-2 warning-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Experience</h4>
<p class="card-open">+</p>
<p class="card-close">-</p>
</div>
<!-- Text -->
<p class="card-text">For more than two decades, FeltonBuford Partners has been providing powerful insights that lead to transformational growth for our clients. From the beginning, our goal has been to be the kind of research firm we would have wanted to hire when we
were on the client side.</p>
</div>
</div>
<div class="choice unset mx-2 success-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Fearless</h4>
<p class="card-open">+</p>
<p class="card-close">-</p>
</div>
<!-- Text -->
<p class="card-text">We have earned the reputation for being fearless. Because of our depth of experience, we have the confidence to tackle the toughest and most complex projects across the globe.</p>
</div>
</div>
<div class="choice unset mx-2 info-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Diverse</h4>
<p class="card-open">+</p>
<p class="card-close">-</p>
</div>
<!-- Text -->
<p class="card-text">Our diversity is a true strength. As a minority and women-owned company, we have a unique appreciation of the diversity of the human experience. We can apply our varied talents and perspectives to a broader and more relevant understanding of the
complex world in which we live.</p>
</div>
</div>
</div>
Or you can use stopPropagation in the close event, the event will be stopped before triggering open e.g
jQuery(".card-close").on("click", function(event) {
event.stopPropagation();
jQuery(".choice").removeClass("expand");
jQuery(".choice").addClass("unset");
jQuery(".choice").removeClass("small");
jQuery(".choice").addClass("unset");
});
Read more about it here: https://developer.mozilla.org/en-US/docs/Web/API/Event/stopPropagation
Use relative addressing
Something like this - run in full screen
$(document).ready(function() {
$(".card-toggle").on("click", function() {
const $parent = $(this).closest(".choice")
$parent.toggleClass("expand");
$parent.toggleClass("unset");
$parent.toggleClass("small");
$parent.toggleClass("unset");
$(this).text($parent.hasClass("expand") ? "+" : "-")
});
})
.container {
display: flex;
width: 100%;
padding: 0;
}
.choice {
height: 40vw;
box-sizing: border-box;
padding: 0;
overflow: hidden;
float: left;
align-items: center;
transition: width 0.2s;
position: relative;
}
.card-body {
z-index: 9;
}
.card-body h4 {
text-align: center;
font-family: 'Poppins', sans-serif !important;
color: #fff;
font-weight: 700;
opacity: .7;
text-decoration: none;
text-transform: uppercase;
margin-bottom: 3px;
width: max-content;
}
.card-body .card-title {
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
text-align: center;
}
.expand .card-body .card-title {
left: 56%;
top: 40%;
}
.card-body .card-title .card-open,
.card-body .card-title .card-close {
color: #000;
background-color: #CBE3A9;
width: max-content;
padding: 0 7px;
font-size: 20px;
margin: 0 auto;
}
.card-body .card-title .card-close,
.expand .card-body .card-title .card-open {
display: none;
}
.expand .card-body .card-title .card-close,
.card-body .card-title .card-open {
display: block;
}
.choice .bg-image {
background-size: cover;
width: 100%;
height: 100%;
position: absolute;
filter: blur(6px);
transition: 1s;
z-index: -9;
}
.danger-color .bg-image {
background-color: green;
}
.warning-color .bg-image {
background-color: blue;
}
.success-color .bg-image {
background-color: red;
}
.info-color .bg-image {
background-color: yellow;
}
.choice.expand .bg-image {
filter: blur(0px);
transition: 1s;
z-index: -999;
}
.expand .card-text {
width: 32%;
background-color: #A7D16D;
padding: 2%;
margin: 0 auto;
position: absolute;
left: 57%;
top: 51.9%;
}
.expand .card-body h4 {
opacity: 1;
font-size: 65px;
}
.small .card-body h4 {
font-size: 25px;
}
.expand {
width: 130%;
}
.unset {
width: 25%;
cursor: pointer;
}
.small .card-title h4 {
display: none;
}
.small {
width: 5%;
cursor: pointer;
background-color: #0000006e;
}
.small>.card-body .card-text {
opacity: 0;
}
.unset>div>p {
opacity: 0;
}
.expand>div {
transition-delay: 200ms;
opacity: 1;
}
.card-toggle { font-size: xx-large }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<div class="container mt-5 justify-content-center">
<div class="choice unset mx-2 danger-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Strategic</h4>
<p class="card-toggle">-</p>
</div>
<!-- Text -->
<p class="card-text">Every FeltonBuford Partners’ insight strategist has worked on the client side. As former leaders of businesses, we can understand the problems our clients face and deliver the level of strategic thinking that leads to true business breakthroughs.</p>
</div>
</div>
<div class="choice unset mx-2 warning-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Experience</h4>
<p class="card-toggle">-</p>
</div>
<!-- Text -->
<p class="card-text">For more than two decades, FeltonBuford Partners has been providing powerful insights that lead to transformational growth for our clients. From the beginning, our goal has been to be the kind of research firm we would have wanted to hire when we
were on the client side.</p>
</div>
</div>
<div class="choice unset mx-2 success-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Fearless</h4>
<p class="card-toggle">-</p>
</div>
<!-- Text -->
<p class="card-text">We have earned the reputation for being fearless. Because of our depth of experience, we have the confidence to tackle the toughest and most complex projects across the globe.</p>
</div>
</div>
<div class="choice unset mx-2 info-color">
<div class="bg-image"></div>
<div class="card-body">
<!-- Title -->
<div class="card-title">
<h4>Diverse</h4>
<p class="card-toggle">-</p>
</div>
<!-- Text -->
<p class="card-text">Our diversity is a true strength. As a minority and women-owned company, we have a unique appreciation of the diversity of the human experience. We can apply our varied talents and perspectives to a broader and more relevant understanding of the
complex world in which we live.</p>
</div>
</div>
</div>

Link Bootstrap with my caroussel's image disappears

I have this carousel which works fine, i need to add the bootstrap 4 style to my page, whenever i add the link, my carousel's pictures disappear.
I tried to figure out if there is anything confusing between the classes but still can't find anything, i also tried to add '!important' to the img tag in css but still can't solve it, what seems to be the problem ? Thanks.
var carousel = document.querySelector('.acc-carousel');
var container = carousel.querySelector('.carousel-container');
var prevBtn = carousel.querySelector('.carousel-prev');
var nextBtn = carousel.querySelector('.carousel-next');
var pagination = carousel.querySelector('.carousel-pagination');
var bullets = [].slice.call(carousel.querySelectorAll('.carousel-bullet'));
var totalItems = container.querySelectorAll('.carousel-item').length;
var percent = (100 / totalItems);
var currentIndex = 0;
function next() {
slideTo(currentIndex + 1);
}
function prev() {
slideTo(currentIndex - 1);
}
function slideTo(index) {
index = index < 0 ? totalItems - 1 : index >= totalItems ? 0 : index;
container.style.WebkitTransform = container.style.transform = 'translate(-' + (index * percent) + '%, 0)';
bullets[currentIndex].classList.remove('active-bullet');
bullets[index].classList.add('active-bullet');
currentIndex = index;
}
bullets[currentIndex].classList.add('active-bullet');
prevBtn.addEventListener('click', prev, false);
nextBtn.addEventListener('click', next, false);
pagination.addEventListener('click', function(e) {
var index = bullets.indexOf(e.target);
if (index !== -1 && index !== currentIndex) {
slideTo(index);
}
}, false);
.text{
position: absolute;
/* width: 100px; */
/* height: 50px; */
background-color: red;
top: 52%;
left: 44%;
text-align: center;
transform: translate(0%, 50%);
}
.container {
width: 80%;
margin: 0 auto;
}
.carousel-item > div {
height: 400px;
line-height: 500px;
font-size: 1.5em;
text-align: center;
color: #fff;
}
img {
width: 100%;
height: 100%;
}
/* Carousel */
.acc-carousel {
position: relative;
overflow: hidden;
height: 300px;
width: 100%;
}
.carousel-container {
list-style: none;
overflow: hidden;
padding: 0;
margin: 0;
width: 500%;
transition: transform 0.3s cubic-bezier(.694, .0482, .335, 1);
}
.carousel-item {
position: relative;
float: left;
width: 20%;
}
/* Next / Prev Buttons */
.carousel-prev,
.carousel-next {
position: absolute;
top: 50%;
background-color: #222;
opacity: 0.7;
border-radius: 50%;
color: #fff;
font-size: 1em;
cursor: pointer;
width: 40px;
height: 40px;
line-height: 40px;
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
text-align: center;
z-index: 10;
transition: opacity 0.3s ease;
}
.carousel-prev {
left: 2%;
padding-right: 3px;
}
.carousel-prev::before {
content: '\f053';
font-family: "FontAwesome";
}
.carousel-next {
right: 2%;
padding-left: 3px;
}
.carousel-next::before {
content: '\f054';
font-family: "FontAwesome";
}
.carousel-prev:hover,
.carousel-next:hover {
opacity: 1;
}
/* Pagination */
.carousel-pagination {
list-style: none;
position: absolute;
bottom: 3%;
left: 0;
right: 0;
width: 50%;
padding: 0;
margin: 0 auto;
text-align: center;
z-index: 10;
}
.carousel-bullet {
display: inline-block;
width: 12px;
height: 12px;
background-color: #000;
cursor: pointer;
margin: 0 7px;
border-radius: 50%;
opacity: 0.5;
transition-property: transform, opacity, background-color;
transition-duration: 0.3s;
}
.carousel-bullet:hover {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
.carousel-bullet.active-bullet,
.carousel-bullet.active-bullet:hover {
opacity: 1;
-webkit-transform: scale(1.3);
transform: scale(1.3);
background-color: #fff;
cursor: default;
}
<!--If i link Bootstrap 4 css, pictres will disappear -->
<!-- Bootstrap 4 css :
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.css'>
<div class="container">
<div class="acc-carousel">
<div class="carousel-prev"></div>
<div class="carousel-next"></div>
<ul class="carousel-pagination">
<li class="carousel-bullet"></li>
<li class="carousel-bullet"></li>
<li class="carousel-bullet"></li>
<li class="carousel-bullet"></li>
<li class="carousel-bullet"></li>
</ul>
<ul class="carousel-container">
<li class="carousel-item">
<div class="item-1 img-fluid">
<img src="https://image.shutterstock.com/image-photo/mountains-during-sunset-beautiful-natural-260nw-407021107.jpg" />
</div>
<p class="text">First image</p>
</li>
<li class="carousel-item">
<div class="item-2 img-fluid">
<img src="https://cdn.pixabay.com/photo/2015/04/19/08/32/marguerite-729510__340.jpg" />
</div>
<p class="text">Second image</p>
</li>
<li class="carousel-item">
<div class="item-3"></div>
</li>
<li class="carousel-item">
<div class="item-4"></div>
</li>
<li class="carousel-item">
<div class="item-5"></div>
</li>
</ul>
</div>
</div>

How to animate menu slide up using css animations?

I am working on a pure css based menu. I tried to create a slide up animation of the menu but couldn't get it to work. I looked at a lot of solutions online but none of them worked for my case.
Here's the laydown of my case.
The menu has a title and subitems (submenu). This menu will only be one level.
I need the height of the submenu to zap behind the menu title.
Since the number of sub items are dynamic I want to achieve this without using specific height.
transform: translateY seemed like a better option but the menu items are visible above the title.
I do not want the menu items to appear above the menu title and use translate or something similar.
I'm not sure if I'm on the right track or if I'm missing something elementary.
$(function() {
$('.accordion-tabs__header').click(function() {
$('.accordion-tabs__body').toggleClass('collapsed');
$('.accordion-tabs__body').toggleClass('expanded');
});
});
.accordion-tabs {
position: relative;
top: 2rem;
width: 60%;
}
.accordion-tabs__header {
transition-delay: 1s;
display: flex;
align-items: center;
padding: 1rem 0.5rem;
z-index: 10;
position: relative;
background-color: azure;
}
.accordion-tabs__header__title {
margin: 0;
padding: 0;
}
.accordion-tabs__body {
position: absolute;
width: 100%;
transition: 200ms transform ease-in-out;
}
.accordion-tabs__body.expanded {
z-index: 1;
transform: translateY(0%);
}
.accordion-tabs__body.collapsed {
z-index: 1;
transform: translateY(-100%);
}
.accordion-tabs__body .accordion-tabs__body__link {
display: flex;
align-items: center;
padding: 0.875rem;
background-color: antiquewhite;
}
.accordion-tabs__body .accordion-tabs__body__link a{
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='wrapper'>
<div class="accordion-tabs">
<div class="accordion-tabs__header">
<div class="accordion-tabs__header__title">Menu Title Looong</div>
</div>
<div class="accordion-tabs__body collapsed">
<div class="accordion-tabs__body__link"><a class="link" href="#">Item One</a></div>
<div class="accordion-tabs__body__link"><a class="link" href="#">Item One</a></div>
<div class="accordion-tabs__body__link"><a class="link" href="#">Item Three</a></div>
</div>
</div>
</div>
Here's the codepen to my code - https://codepen.io/flexdinesh/pen/VybwwE
I managed to achieve this with max-height.
Slide-up animation was a bit slow to trigger when I used this code in react. However I made it look okay with ease-out transition.
$(function() {
$('.accordion-tabs__header').click(function() {
$('.accordion-tabs__body').toggleClass('collapsed');
$('.accordion-tabs__body').toggleClass('expanded');
});
});
.accordion-tabs {
position: relative;
top: 2rem;
width: 60%;
}
.accordion-tabs__header {
transition-delay: 1s;
display: flex;
align-items: center;
padding: 1rem 0.5rem;
position: relative;
background-color: azure;
}
.accordion-tabs__header__title {
margin: 0;
padding: 0;
}
.accordion-tabs__header.expanded {
border-bottom: none;
}
.accordion-tabs__body {
overflow: hidden;
position: absolute;
width: 100%;
border-bottom-width: 2px;
border-bottom-style: solid;
}
.accordion-tabs__body.expanded {
max-height: 100vh;
transition: max-height 500ms ease-in;
}
.accordion-tabs__body.collapsed {
max-height: 0;
transition: max-height 200ms ease-out;
}
.accordion-tabs__body__link {
display: flex;
align-items: center;
padding: 0.875rem;
border-top-width: 1px;
border-top-style: solid;
background-color: antiquewhite;
}
.accordion-tabs__body__link a {
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='wrapper'>
<div class="accordion-tabs">
<div class="accordion-tabs__header">
<div class="accordion-tabs__header__title">Menu Title Looong</div>
</div>
<div class="accordion-tabs__body collapsed">
<div class="accordion-tabs__body__link"><a class="link" href="#">Item One</a></div>
<div class="accordion-tabs__body__link"><a class="link" href="#">Item One</a></div>
<div class="accordion-tabs__body__link"><a class="link" href="#">Item Three</a></div>
</div>
</div>
</div>
Here's the updated codepen that works -
https://codepen.io/flexdinesh/pen/VyWzKo

One part of html page disappeared in google but it is normal in firefox

One part of this html page disappeared in google chrome,but it is OK in firefox .I check the console part of browser ,every element is right,but it just can't appear in google chrome.here are the pictures,I add a roll animation to the two little balls.I don't think it was the animation cause the disappearence, because I delete the animation jquery file,but nothing changed...
<div class="advantage" >
<div class="adv_wrapper">
<div class="adv_header">
<div class="line2 horizon2"></div>
<div class="adv_title horizon2">ADVANTAGE</div>
<div class="line2 horizon2"></div>
</div>
<div class="adv_content">
<div class="ball_content">
<div class="ball1 ball">
<div class="ball1_inner"><img src="images/adv/left.png"></div>
</div>
<div class="ball2 ball"></div>
<div class="ball3 ball">
<div class="ball3_inner"><img src="images/adv/right.png"></div>
</div>
</div>
<div class="target"></div>
<div class="target_des">
<a class="szll item" href="">AAA</a>
<a class="zczz item" href="">BBB</a>
<a class="yjjs item" href="">CCC</a>
<a class="zyhz item" href="">DDD</a>
</div>
</div>
css:
.advantage .target{
width: 100%;
height: 340px;
background:url(../images/adv/target.png);
/*border:solid 1px red;*/
}
.target_des{
/*border:solid 1px black;*/
height: 100px;
}
.target_des>.item{
float: left;
font-family: "黑体";
font-size: 18px;
color: rgb(160,160,167);
width: 90px;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 5px;
/*border:solid 1px red;*/
}
.target_des>.item::after {
content: "";
border-radius: 5px;
position: absolute;
z-index: -1;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
opacity: 0;
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transform: background-color .3s;
}
.target_des>.item:hover {
background-color: rgb(30,148,211);
color: white;
-webkit-transform: scale(1.15, 1.15);
transform: scale(1.15, 1.15);
}
.target_des>.item:hover::after {
opacity: 1;
}
.szll{
display: inline-block;
margin-left: 40px;
margin-right: 165px;
}
.zczz{
display: inline-block;
margin-right: 300px;
}
.yjjs{
display: inline-block;
margin-right: 170px;
}
js:
$(document).ready(function(){
setInterval(function(){
$(".ball1_inner").addClass("roll-left").one('animationend',function(){
$(this).removeClass("roll-left");
$(".ball3_inner").addClass("roll-right").one('animationend',function(){
$(this).removeClass("roll-right");
})
})
},8000);
})
in google chrome
in firefox