why my <div></div> is overlaying on another div on small screen - css

Whenever I check the responsiveness and check it on the small screen my one div starts overlaying another div. I have tried the ```position : relative and overflow: hidden as well but it makes no sense call you please tell me what I have to do to stop it from being overlaying another div
my HTML code is :
<div class="container-grid">
<div class="grid_upper">
<h1 class="grid_Heading">My recent projects</h1>
<div class="grid_para">
Ask me a Question if you are unable to solve it.
</div>
</div>
<div class="cardContainer1">
<div class="container">
<div class="row">
<div class="col-sm">
<div class="card h-200">
<img
src="./istockphoto-1074239826-170667a.jpg"
class="card-img-top"
alt="..."
/>
<div class="card-footer">
<small class="card_text_1">Business</small>
<small class="text-muted"> 3 mins</small>
</div>
<div class="card-body">
<h5 class="card-title">Card </h5>
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
</div>
<div class="card-footer footerNo2">
<img class="shortImg" src="./istockphoto-1074239826-170667a.jpg" alt="">
<div class="FooterInsideContainer">
<small class="text"> Micheal Corleone</small>
<small class="text-muted"> Senior web developer</small>
</div>
</div>
</div>
</div>
<div class="col-sm">
<div class="card h-200">
<img
src="./istockphoto-1272685152-612x612.jpg"
class="card-img-top"
alt="..."
/>
<div class="card-footer">
<small class="card_text_1">Business</small>
<small class="text-muted"> 3 mins</small>
</div>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
</div>
<div class="card-footer footerNo2">
<img class="shortImg" src="./istockphoto-1074239826-170667a.jpg" alt="">
<div class="FooterInsideContainer">
<small class="text"> Micheal Corleone</small>
<small class="text-muted"> Senior web developer</small>
</div>
</div>
</div>
</div>
<div class="col-sm">
<div class="card h-200">
<img
src="./photo-1473090826765-d54ac2fdc1eb.jpg"
class="card-img-top"
alt="..."
/>
<div class="card-footer">
<small class="card_text_1">Business</small>
<small class="text-muted"> 3 mins</small>
</div>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
</div>
<div class="card-footer footerNo2">
<img class="shortImg" src="./istockphoto-1074239826-170667a.jpg" alt="">
<div class="FooterInsideContainer">
<small class="text"> Micheal Corleone</small>
<small class="text-muted"> Senior web developer</small>
</div>
</div>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-sm-4">
<div class="card h-200">
<img
src="./creative-book-cover-design-vintage-260nw-1115305040.webp"
class="card-img-top"
alt="..."
/>
<div class="card-footer">
<small class="card_text_1">Business</small>
<small class="text-muted"> 3 mins</small>
</div>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
</div>
<div class="card-footer footerNo2">
<img class="shortImg" src="./istockphoto-1074239826-170667a.jpg" alt="">
<div class="FooterInsideContainer">
<small class="text"> Micheal Corleone</small>
<small class="text-muted"> Senior web developer</small>
</div>
</div>
</div>
</div>
<div class="col-sm-8" style="background-color: white;">
<div class="card card2 h-200" >
<img style="width: 100%;"
src="./wide-view-image-young-woman-paddling-sup-board-calm-morning-sea-water-rear-view_254268-2063.jpg"
class="card-img-top"
alt="..."
/>
<div class="card-footer laster">
<small class="card_text_1">Business</small>
<small class="text-muted"> 3 mins</small>
</div>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural
lead-in to additional content. This content is a little bit
longer.
</p>
</div>
<div class="card-footer footerNo2_laster">
<img class="shortImg" src="./istockphoto-1074239826-170667a.jpg" alt="">
<div class="FooterInsideContainer">
<small class="text" style="color: black;"> Micheal Corleone</small>
<small class="text-muted"> Senior web developer</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="Approach">
<div class="app_head">
<h1 class="main_approach_Heading">My approach</h1>
</div>
<div class="container">
<div class="row row-cols-1 row-cols-md-3 g-4">
<div class="col">
<div class="card h-100">
<!-- <img src="..." class="card-img-top" alt="..."> -->
<h1 class="pic_char no1">1</h1>
<div class="card-body">
<h5 class="card-title">We will sit and talk drinking coffee</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
<div class="card-footer approach_footer">
<div class="triangle arrow-up"></div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<!-- <img src="..." class="card-img-top" alt="..."> -->
<h1 class="pic_char no2">2</h1>
<div class="card-body">
<h5 class="card-title">We will sketch some ugly Frameworks</h5>
<p class="card-text">This card has supporting text below as a natural lead-in to additional content text below as a natural lead-in to additional content.</p>
</div>
<div class="card-footer approach_footer">
<div class="app_circle"> </div>
</div>
</div>
</div>
<div class="col">
<div class="card h-100">
<!-- <img src="..." class="card-img-top" alt="..."> -->
<h1 class="pic_char no3">3</h1>
<div class="card-body">
<h5 class="card-title">You will pay alot for my services</h5>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
</div>
<div class="card-footer approach_footer">
<div class="triangle arrow-up"></div>
</div>
</div>
</div>
</div>
</div>
</div>
and the CSS code is :
.grid_upper {
display: flex;
flex-direction: column;
width: 67%;
margin: auto;
}
.grid_Heading {
font-size: clamp(2em, 2.5vw, 7em);
padding: 0.5em 0.21em 0em 0em;
color: white;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
.grid_para {
color: white;
}
.container-grid {
display: flex;
position: relative;
height: 160vh;
overflow: visible;
flex-wrap: wrap;
background-color: #3e4245;
}
.cardContainer1 {
position: relative;
display: flex;
flex-wrap: wrap;
padding: 2em 0em;
width: 70%;
margin: auto;
}
.cardContainer2 {
position: relative;
display: flex;
flex-wrap: wrap;
padding: 2em 0em;
width: 70%;
margin: auto;
}
.card {
background-color: #252728;
border: none;
border-radius: 20px;
height: 100%;
}
.card2 {
background-color: white;
}
.card2 .card-title {
color: black;
}
.card2 .card-text {
color: grey;
}
.card-title {
color: white;
}
.card-text {
color: rgba(255, 255, 255, 0.522);
}
.card-footer {
display: flex;
align-items: center;
justify-content: space-between;
color: rgba(255, 255, 255, 0.522);
background-color: #252728;
/* background-color: red; */
margin: none;
border: none;
}
.card_text_1 {
color: rgba(255, 255, 0, 0.659);
}
.card-img-top {
width: 100%;
height: 25vh;
object-fit: cover;
}
.shortImg {
height: 40px;
width: 40px;
border-radius: 50%;
}
.footerNo2 {
display: flex;
align-items: flex-start;
justify-content: flex-start;
/* flex-direction: column; */
padding: 1em 1em;
/* background-color: aqua; */
}
.footerNo2_laster {
display: flex;
align-items: flex-start;
justify-content: flex-start;
background-color: white;
}
.FooterInsideContainer {
display: flex;
flex-direction: column;
padding: 0em 1em;
}
.laster {
background-color: white;
}
.laster .card_text_1 {
color: skyblue;
}
.Approach {
position: relative;
/* overflow: hidden; */
height: 100vh;
width: 100%;
margin-top: 10em;
}
.app_head {
padding: 7em 5em;
display: flex;
font-weight: bold;
/* background-color: red; */
}
.main_approach_Heading {
font-size: clamp(1.5rem, 10.5vw, 4rem);
font-family: "Roboto", sans-serif;
margin: auto;
text-align: center;
}
.pic_char {
background-repeat: repeat;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
/* margin-top: 200px; */
text-align: center;
font-weight: bold;
text-transform: uppercase;
/* font-family: 'Times New Roman', Times, serif; */
font-weight: 800;
-webkit-font-smoothing: antialiased;
}
.no1 {
background-image: url("./istockphoto-1288917639-170667a.jpg");
font-family: "Montserrat Alternates", sans-serif;
font-size: 13em;
}
.no2 {
background-image: url("./polygonal-square-background-black-blue-purple-vector-21357114.jpg");
/* font-family: 'Anton', sans-serif; */
font-size: 12em;
}
.no3 {
background-image: url("./android-marshmallow-6-hd-orange-yellow-and-gray-blocks-illustrarion-wallpaper-preview.jpg");
font-size: 12em;
}
.Approach .card {
display: flex;
background-color: white;
color: black;
/* width: 50%; */
}
.Approach .card-body {
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
justify-content: center;
padding: 0em 4em;
/* background-color: pink; */
}
.Approach .card-title {
color: black;
font-weight: 700;
font-size: 1.4em;
font-feature-settings: "vrt2";
}
.Approach .card-text {
color: grey;
text-align: center;
}
.approach_footer {
background-color: white;
display: flex;
align-items: center;
justify-content: center;
color: grey;
}
.arrow-up {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 20px solid white;
box-shadow: -1px -1px 10px -2px rgba(0, 0, 0, 0.5);
}
.app_circle{
width: 25px;
height: 25px;
border-radius: 50%;
background-color: white;
box-shadow: -1px -1px 10px -2px rgba(0, 0, 0, 0.5);
}

Related

Carousel doesn't work (have 2 carousel one page)

I have 2 Carousel in one page the fist one slides and indicators are working really good, but the second doesn't automatically slides and the buttons don't even work
tried a lot of stuff scripting didn't seem to work.
<header>
<div id="myCarousel" class="carousel slide" data-bs-ride="carousel" data-bs-interval="4000">
<ol class="carousel-indicators">
<li data-bs-target="#myCarousel" data-bs-slide-to="0" class="active"></li>
<li data-bs-target="#myCarousel" data-bs-slide-to="1"></li>
<li data-bs-target="#myCarousel" data-bs-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container first-item">
<h1>Welcome to my protfolio</h1>
<!-- About me -->
Contact Me
</div>
</div>
<div class="carousel-item">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-3 col-lg-3 col-xl-3 col-xxl-3"> Work Experience</div>
<div class="col-3 col-lg-3 col-xl-3 col-xxl-3">Education</div>
<div class="col-3 col-lg-3 col-xl-3 col-xxl-3">Skills</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container">
<!-- About me -->
<h1>Third Item</h1>
</div>
</div>
</div>
</div>
</header>
<!-- #Main Body -->
<div class="container-fluid main">
<!-- #About -->
<div class="row section" id="about">
<div class="col-8">Column</div>
<div class="col-4">Column</div>
</div>
<!-- #Jobs -->
<div class="row section" id="jobs">
<div class="col-6 col-xl-6 col-xxl-6">
<div class="card">
<img src="StyleSheet/Working.jpg" class="card-img-top" />
<!---Card For Work Experience------------------>
<div class="card-body">
<h5 class="card-title">work experience</h5>
<p class="card-text "></p>
My Resume
</div>
</div>
</div>
<div class="col-6 col-xl-6 col-xxl-6 ">
<div class="container ">
<div class="row justify-content-center ">
<div class="col-12 ">
<h1>
<span class="material-icons-round "> work_history </span> Work Experience
</h1>
</div>
</div>
<div class="row ">
<figure>
<blockquote class="blockquote ">
<li>Bright Data ( former Luminati )</li>
</blockquote>
<figcaption class="blockquote-footer ">
( 2021 - Current )
</figcaption>
</figure>
</div>
<div class="row ">
<figure>
<blockquote class="blockquote ">
<li>Rafael Industry</li>
</blockquote>
<figcaption class="blockquote-footer ">
( 2017 - 2019 )
</figcaption>
</figure>
</div>
<div class="row ">
<figure>
<blockquote class="blockquote ">
<li>IDF</li>
</blockquote>
<figcaption class="blockquote-footer ">
( 2014 - 2017 )
</figcaption>
</figure>
</div>
</div>
</div>
</div>
<!-- #Projects -->
<div class="row section justify-content-center">
<!-- #Projects-Carousel -->
<div id="projects-carousel " class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner ">
<!-- #Projects-1 -->
<div class="carousel-item active ">
<div class="container ">
<div class="row justify-content-center ">
<img class="col-lg-8 " src="StyleSheet/Working.jpg " />
<div class="col-xl-3 col-md-4 card ">
<div class="card-header text-center ">
Featured
</div>
<img src="StyleSheet/Working.jpg " class="card-img " />
<div class="card-body ">
<h5 class="card-title ">Special title treatment</h5>
<p class="card-text ">With supporting text below as a natural lead-in to additional content.</p>
<center>
<a class="github-ref ">
<i class="fa-brands fa-github fa-2x "></i>
</a>
</center>
</div>
<div class="card-footer text-muted text-center ">
2 days ago
</div>
</div>
</div>
</div>
</div>
<!-- #Projects-2-->
<div class="carousel-item ">
</div>
<!-- #Projects-3-->
<div class="carousel-item ">
</div>
</div>
<button class="carousel-control-prev" type="button " data-bs-target="#projects-carousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon " aria-hidden="true "></span>
<span class="visually-hidden ">Previous</span>
</button>
<button class="carousel-control-next" type="button " data-bs-target="#projects-carousel" data-bs-slide="next">
<span class="carousel-control-next-icon " aria-hidden="true "></span>
<span class="visually-hidden ">Next</span>
</button>
</div>
</div>
</div>
<!-- #footer -->
<footer></footer>
<!-- Scripst-->
<script src="script.js "></script>
<!-- JavaScript Bundle with Popper -->
</body>
adding the css file maybe something is wrong there, it is my first website doing it all alone so kind of messy.
body {
background-image: url("Background.png");
background-repeat: no-repeat;
font-family: 'Arima Madurai', cursive;
background-size: cover;
}
header .carousel-item {
height: 48rem;
background-color: #e6f2ff;
position: relative;
border: 2px;
}
header .first-item {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding-bottom: 50px;
}
.carousel-indicators [data-bs-target] {
background-color: #131acf;
}
.main {
margin: 0;
}
.main>.row {
margin: 10px;
width: 100%;
border-radius: 25px;
}
.card {
box-shadow: 5px -10px rgba(0, 0, 0, 0.2);
margin: 5px;
border: solid 1px #555;
}
.container .col-12 {
background-color: #668cff;
border-radius: 25px;
color: #0033cc;
border: solid 1px #555;
box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.2);
-o-box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.6);
border-radius: 25px;
}
.blockquote-footer {
color: #e6ffff;
font-size: 16px;
}
.section {
height: 46.5rem;
}
.row>figure {
background-color: #6675ff;
margin-top: 20px;
border: solid 1px #555;
box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.2);
-o-box-shadow: 10px -10px 5px rgba(0, 0, 0, 0.6);
border-radius: 25px;
}
header .col-3 {
border-radius: 25px;
margin: 10px;
height: 45rem;
text-align: center;
background-color: #e6e5e5;
}
.section .card {
box-shadow: none;
}
.section .col-4>.card::before {
content: "";
position: absolute;
height: 40%;
width: 100%;
background-color: #0033cc;
}
.section .col-4 .card>img {
border-radius: 50%;
/* width: 10.5vw;
height: 10.5vw; */
align-self: center;
border: solid 3px blue;
z-index: 100;
margin-top: 10px;
}
.fa-brands {
cursor: pointer;
}
.carousel-item .card {
height: 450px;
margin-left: -25%;
margin-top: 45px;
width: 500px;
}
.carousel-item .card .card-img {
display: none;
}
#media screen and (max-width:790px) {
.carousel-item img {
display: none;
}
.carousel-item .card {
height: 520px;
align-self: center;
margin-top: 0;
margin-left: 0;
}
.carousel-item .card .card-body {
align-self: center;
}
.carousel-item .card .card-body {
align-self: center;
}
.carousel-item .card .card-img {
display: block;
}
.card .card-header {
display: none;
}
}
#media screen and (min-width:790px) and (max-width:990px) {
.carousel-item .card {
height: 320px;
align-self: center;
margin-top: -120px;
margin-left: 0;
}
.carousel-item .card .card-body {
align-self: center;
}
.carousel-item .card .card-body {
align-self: center;
}
}
carousel-control-next {
color: black
}

Keep left margin of a div inline with another div when resizing

the problem that I'm having is that when I resize the browser the left margins of both the and my card divs aren't aligning. Is there some sort of css property or maybe some JS that will make them stay aligned when resizing?
here's my sandbox
https://codesandbox.io/s/stupefied-christian-tosys?file=/src/styles.css:0-
Add the .filter margin margin: 0 80px; to your .row. and then remove justify-content: center;. It will loose the centered. But will be align on the left. To aviod the overflow from the body, you can set width: calc(100% - 160px);to your .row:
/* ADDED BELOW */
margin: 0 80px;
justify-content: unset;
width: calc(100% - 160px);
After if you want to keep your card more center, either you use justify-content: space-between; on row, either you use margin: 10px auto; on your card.
DEMO:
body {
margin: 0 auto;
max-width: 1200px;
}
.row {
display: flex;
justify-content: center;
width: 100%;
flex-wrap: wrap;
/*ADDED BELOW */
margin: 0 80px;
justify-content: unset;
width: calc(100% - 160px);
}
.filter {
display: flex;
margin: 0 80px;
}
.filter select {
display: inline;
width: 15rem;
margin: 10px;
border-radius: 5px;
}
.card {
width: 15rem;
margin: 10px;
border-radius: 5px;
border: 1px solid rgba(0, 0, 0, 0.125);
}
.info {
padding: 15px;
}
.img-container {
padding-top: 0;
position: relative;
}
.card img {
width: 100%;
object-fit: cover;
}
.price {
font-weight: bold;
}
<div id="root">
<div class="App">
<div class="filter-container">
<div class="product-listing-wrap">
<div class="filter">
<select class="custom-select" id="priceGroup">
<option value="1">Under $50</option>
<option value="2">$50 to $100</option>
<option value="3">$100 to $250</option>
<option value="4">Over $250</option>
</select>
</div>
<div class="row" style="
margin: 0 80px;
padding: 10px 0;
width: calc(100% - 160px);
">
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="1"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="2"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="3"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="4"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="5"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="6"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="7"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
<div class="card">
<div class="img-container"><img src="https://images.pexels.com/photos/593171/pexels-photo-593171.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" alt="8"></div>
<div class="info">
<p class="info-title"><span><a>placeholder...</a></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
try it:
.row {
display: flex;
justify-content: space-between;
margin: 0 80px;
max-width: 1040px;
flex-flow: wrap;
}

CSS Flexbox - Aligning by card description

I have a simple card layout and I want to align it by the card description.
Can anyone help me, please? :)
Here is a Pen: CODEPEN
Here is my HTML structure:
<div class="card-container">
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">A veeeeery very very very large title</h4>
<p class="card-desc">omg, that description have broken :(</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
</div>
By changing the .card elements to
display: flex;
flex-direction: column;
and adding margin-top: auto; to the descriptions. This will cause the description element to be pushed to the bottom of the card. Because the cards are stretched vertically, the alignment works on the horizontal axis. This would not be the case if you changed align-items on the .card-container to be something other than stretch.
.card {
display: flex;
flex-direction: column;
text-align: center;
flex: 50%;
padding: 15px 0;
}
.card-img img {
width: 60px;
padding: 15px;
}
.card-title {
font-weight: 700;
text-transform: uppercase;
margin-bottom: 10px;
font-size: 1.2rem;
}
.card-desc {
font-weight: 400;
margin: 0;
margin-top: auto;
line-height: 1rem;
}
.card-container {
background: rgba(255, 0, 0, 0.432);
display: flex;
flex-wrap: wrap;
justify-content: center;
flex: 100%;
}
#media screen and (min-width: 500px) {
.card {
flex: 1;
}
.card-img img {
width: 50px;
}
.card-title {
font-weight: 700;
text-transform: uppercase;
margin-bottom: 10px;
font-size: 1.2rem;
}
.card-desc {
font-weight: 400;
line-height: 1rem;
}
.card-container {
background: rgba(255, 0, 0, 0.432);
display: flex;
flex-wrap: wrap;
justify-content: center;
flex: 100%;
}
}
<div class="card-container">
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">A veeeeery very very very large title</h4>
<p class="card-desc">omg, that description have broken :(</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
<div class="card">
<div class="card-img"><img src="https://via.placeholder.com/500x500"></div>
<h4 class="card-title">Just a title</h4>
<p class="card-desc">A simple description</p>
</div>
</div>

Firefox not hiding the backside of a card when flipped using 3d css transitions

I am using CSS 3d transitions to put some text on the backside of a card. On hover, the card flips around and displays the text.
This works great on Chrome; however, on Firefox, the front side of the card remains visible when flipped.
Can anyone help me with CSS that works across all browsers?
https://codepen.io/anon/pen/gdqNxo
HTML:
<div id="fws_5ba42198264cd" class="vc_row vc_row-fluid animate_onoffset row-dynamic-el standard_section home-grid-row discover-grid-row location-four-grid-row bring-up-five-px " style=""><div id="home-grid-row discover-grid-row location-four-grid-row bring-up-five-px" style="position: absolute;top: 0;"></div><div class="container dark"><div class="section_clear">
<div class="vc_col-sm-6 make-look-pretty vc_column column_container with_padding vc_custom_1537378625076 vc_custom_1537378625076" style="padding:" data-animation="none" data-delay="">
<div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<h2 class="white">
</div>
</div>
</div>
</div>
<div class="vc_col-sm-6 locations-four-grid four-grid-height vc_column column_container with_padding " style="padding:" data-animation="none" data-delay="">
<div class="wpb_wrapper">
<div class="vc_row wpb_row vc_inner vc_row-fluid"><div class="students fix-padding four-grid-height wpb_column vc_column_container vc_col-sm-6 vc_col-has-fill"><div class="vc_column-inner vc_custom_1537389883311"><div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div class="card-wrapper">
<div class="side-a">
<h4 class="white uppercase" style="text-align: center;/*! backface-visibility: hidden; */">Card 1</h4>
</div>
<div class="side-b">
<div class="wrapper">
<h5 class="white">Filler Text</h5>
<ul class="white">
<li><a href=#>Link A</a></li>
<li><a href=#>Link B</a></li>
</ul>
</div>
</div>
</div>
</div>
</div> </div></div></div><div class="campus fix-padding columbus-campus wpb_column vc_column_container vc_col-sm-6"><div class="vc_column-inner "><div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div class="card-wrapper">
<div class="side-a">
<h4 class="white uppercase" style="text-align: center;">Card 2</h4>
</div>
<div class="side-b">
<div class="wrapper">
<h5 class="white">Filler</h5>
<ul class="white">
<li>Map</li>
<li><a href=#>LInk B</a></li>
</ul>
</div>
</div>
</div>
</div>
</div> </div></div></div></div><div class="vc_row wpb_row vc_inner vc_row-fluid"><div class="admissions fix-padding wpb_column vc_column_container vc_col-sm-6"><div class="vc_column-inner "><div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div class="card-wrapper">
<div class="side-a">
<h4 class="white uppercase" style="text-align: center;">Card 3</h4>
</div>
<div class="side-b">
<div class="wrapper">
<h5 class="white">Filler</h5>
<ul class="white">
<li><a href=#>Filler</li>
</ul>
</div>
</div>
</div>
</div>
</div> </div></div></div><div style="display:none;" class="connect fix-padding wpb_column vc_column_container vc_col-sm-6"><div class="vc_column-inner "><div class="wpb_wrapper">
<div class="wpb_text_column wpb_content_element ">
<div class="wpb_wrapper">
<div class="card-wrapper">
<div class="side-a">
<h4 class="white uppercase" style="text-align: center;">Connect</h4>
</div>
<div class="side-b">
<div class="wrapper">
<h5 class="white">CONNECT</h5>
<ul class="white">
<li>Blog</li>
<li>Social Media</li>
</ul>
</div>
</div>
</div>
</div>
</div> </div></div></div></div>
</div>
</div>
</div></div></div>
CSS:
/* Setting up the flippy css */
.vc_column_container.fix-padding .vc_column-inner {
padding-right: 0;
padding-left: 0;
padding-top: 0;
}
.locations-four-grid .card-wrapper {
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
display: -webkit-box;
display: -ms-flexbox;
background-repeat: no-repeat;
background-size: cover;
align-items: center;
display: flex;
height: 300px;
padding: 0;
z-index: 2;
}
.locations-four-grid .side-a,
.four-grid.side-a {
display: -webkit-box;
display: -ms-flexbox;
background-repeat: no-repeat;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
background-size: cover;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
display: flex;
width: 100%;
}
.locations-four-grid .side-b,
.four-grid.side-b {
position: absolute;
width: 100%;
z-index: -1;
left: 0;
top: 0;
}
.four-grid-height .side-a,
.four-grid-height .side-b {
height: 300px;
}
.five-grid-height .side-a,
.five-grid-height .side-b {
height: 200px;
}
.card-wrapper {
-webkit-transition: all 1s cubic-bezier(.5,-0.3,.85,1.25);
-o-transition: all 1s cubic-bezier(.5,-0.3,.85,1.25);
transition: all 1s cubic-bezier(.5,-0.3,.85,1.25);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.locations-four-grid .wpb_content_element .wpb_wrapper:hover .card-wrapper,
.locations-five-grid .wpb_content_element .wpb_wrapper:hover .card-wrapper {
-webkit-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.locations-four-grid .wpb_content_element .wpb_wrapper:hover h4,
.locations-five-grid .wpb_content_element .wpb_wrapper:hover h4,
{
display:none;
}
.side-a,
.side-b {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.side-b {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.side-b .wrapper {
padding: 20px;
}
.side-b ul {
list-style-type: none;
}
.side-b h5 {
text-align: center;
line-height: 22px;
font-size: 15px;
}
.side-b a:hover {
color: #fff;
padding: 1px 15px;
background-color: #f9972c;
}
.location-four-grid-row .side-b {
-webkit-box-shadow: inset 0 0 5px #fff;
box-shadow: inset 0 0 5px #fff;
background-color: #87cdec;
}
.locations-five-grid .side-b {
-webkit-box-shadow: inset 0 0 5px #fff;
box-shadow: inset 0 0 5px #fff;
background-color: #f6943b;
}
.vc_col-sm-6 {
width:300px;
margin-bottom: 25px
}
.side-a {
background-color: rebeccapurple;
}
Never mind, found the answer here: Backface-Visibility Not Working Properly in Firefox (Works in Safari).
The key is to add transform: rotateX(0); to the front and back of the card.
Adding backside-visibility: hidden; to the container also works, but it makes the backside of the card inaccessible to the mouse, i.e. you can't click on links on the backside.
I have no idea why this works, but apparently it has been an issue in firefox for three years: https://bugzilla.mozilla.org/show_bug.cgi?id=1201471

CSS masonry problems

I've recently discovered a neat way to do a masonry layout using columns, as found here: http://w3bits.com/css-masonry/. I've expanded on this layout by adding an overlay with text to each item upon hover. This works pretty well except for 2 problems:
The overlay is slightly larger than the image at the bottom. This persists even when different images are used.
The transitions do not work; the hover effect displays and hides abruptly.
Some explanations regarding my code:
I've added margin: 0; border:0; padding:0 to the entire document in an attempt to prevent problems just like this one, to no avail. .item has margin: 0 0 20px to provide vertical spacing between each item.
Because .item-overlay requires position:absolute to work, and position:absolute requires the parent element to be positioned, I've added position:relative to .item. This doesn't affect anything beyond allowing the overlay to show up correctly, as far as I can tell.
.item-overlay uses display:flex to vertically and horizontally centralise its content, but this shouldn't affect the layout.
Could someone help me figure out what's wrong with the code? JSFiddle: https://jsfiddle.net/nattanyz/sfn47me9/1/
Use vertical-align: top on the img and transition opacity instead of display
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
background-color: honeydew;
font-size: 16px;
line-height: 120%;
color: #333;
margin: 0;
padding: 0;
}
.wrapper {
min-height: 100vh;
width: 80vw;
max-width: 1200px;
margin: auto;
border: 0;
padding: 0;
column-count: 3;
column-gap: 20px;
}
.item {
display: block;
margin: 0 0 20px;
border: 0;
width: 100%;
position: relative;
}
.item-overlay {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 100%;
background-color: rgb(51, 51, 51, 0.6);
color: white;
opacity: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: rgba(51, 51, 51, 0.6);
transition: opacity 300ms ease;
}
.item:hover .item-overlay {
opacity: 1;
}
.project-img {
width: 100%;
margin: 0;
border: 0;
padding: 0;
vertical-align: top;
}
.project-name {
font-weight: bold;
}
.project-category {
font-size: 0.75em;
text-transform: uppercase;
<body>
<div class="wrapper">
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb" />
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
</div>
</body>
The overlay is slightly larger than the image at the bottom. This persists even when different images are used.
The problem is on the image itself, it has height smaller than the container. Try to put some background-color on the container, you will see that the overlay height is equal with it's parent.
The transitions do not work; the hover effect displays and hides abruptly.
You cannot implements transition on the css display, other alternative would be using opacity. I modified your code, please try.
html {
box-sizing:border-box;
}
*, *:before, *:after {
box-sizing:inherit;
}
body {
background-color:honeydew;
font-size: 16px;
line-height: 120%;
color: #333;
margin: 0;
padding: 0;
}
.wrapper {
min-height: 100vh;
width: 80vw;
max-width:1200px;
margin: auto;
border: 0;
padding: 0;
column-count: 3;
column-gap: 20px;
}
.item {
display:block;
margin: 0 0 20px;
border:0;
width:100%;
position:relative;
background-color: black;
}
.item-overlay {
position:absolute;
top:0;
left:0;
bottom:0;
width:100%;
background-color: rgba(51,51,51,0.6);
color:white;
opacity:0;
transition:300ms ease opacity;
display: flex;
flex-direction:column;
justify-content:center;
align-items:center;
}
.item:hover .item-overlay {
opacity: 1;
background-color: rgba(51,51,51,0.6);
}
.project-img {
width:100%;
margin:0;
border:0;
padding:0;
}
.project-name {
font-weight:bold;
}
.project-category {
font-size:0.75em;
text-transform:uppercase;
<body>
<div class="wrapper">
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
<div class="item">
<img class="project-img" src="https://images.pexels.com/photos/297755/pexels-photo-297755.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"/>
<div class="item-overlay">
<p class="project-name">Project Name</p>
<p class="project-category">Commercial</p>
</div>
</div>
</div>
</body>

Resources