cards responsive for smallaer screens img being cut - css

i have a card that no matter what i did to it i could not make it a perfect responsive for smaller screens some of the images will cut off i need to make it very small for that then the medum screen will be ruined i dont know what to do here is my codes
and here is some images of how it looks like and what will happen when it is on small screen
big screen small screen like you see in both sides the it cuts the image can anyone help me with this ?
*{
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
h1{
font-size: 2.5rem;
font-family: 'Montserrat';
font-weight: normal;
color: #444;
text-align: center;
margin: 2rem 0;
}
.wrapper{
width: 100%;
margin: 0 auto;
max-width: max-width: 80rem;;
}
.cols{
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.col{
width: calc(25% - 2rem);
margin: 1rem;
cursor: pointer;
}
.container{
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-perspective: 1000px;
perspective: 1000px;
}
.front,
.back{
word-wrap: break-word;
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* Opera <7 */
white-space: -o-pre-wrap; /* Opera 7 */
background-size: 400px 400px;
background-position: center;
background-repeat: no-repeat;
-webkit-transition: -webkit-transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
transition: -webkit-transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
-o-transition: transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
transition: transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
transition: transform .7s cubic-bezier(0.4, 0.2, 0.2, 1), -webkit-transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
text-align: center;
min-height: 400px;
min-width: 200px;
height: auto;
border-radius: 10px;
color: #fff;
font-size: 0.8rem;
text-overflow: ellipsis;
}
.back{
background-color: #000;
background: -webkit-linear-gradient(45deg, #cedce7 0%,#596a72 100%);
background: -o-linear-gradient(45deg, #cedce7 0%,#596a72 100%);
background: linear-gradient(45deg, #cedce7 0%,#596a72 100%);
}
.front:after{
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 100%;
content: '';
display: block;
opacity: .3;
background-color: #000;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
border-radius: 10px;
}
.container:hover .front,
.container:hover .back{
-webkit-transition: -webkit-transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
transition: -webkit-transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
-o-transition: transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
transition: transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
transition: transform .7s cubic-bezier(0.4, 0.2, 0.2, 1), -webkit-transform .7s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.back{
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.inner{
-webkit-transform: translateY(-50%) translateZ(60px) scale(0.94);
transform: translateY(-50%) translateZ(60px) scale(0.94);
top: 50%;
position: absolute;
left: 0;
width: 100%;
padding: 2rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
outline: 1px solid transparent;
-webkit-perspective: inherit;
perspective: inherit;
z-index: 2;
}
.container .back{
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.container .front{
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.container:hover .back{
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.container:hover .front{
-webkit-transform: rotateY(-180deg);
transform: rotateY(-180deg);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.front .inner p{
font-size: 2rem;
margin-bottom: 2rem;
position: relative;
}
.front .inner p:after{
content: '';
width: 4rem;
height: 2px;
position: absolute;
background: #C6D4DF;
display: block;
left: 0;
right: 0;
margin: 0 auto;
bottom: -.75rem;
}
.front .inner span{
color: rgba(255,255,255,0.7);
font-family: 'Montserrat';
font-weight: 300;
}
#media screen and (max-width: 64rem){
.col{
width: calc(33.333333% - 2rem);
}
}
#media screen and (max-width: 48rem){
.col{
width: calc(50% - 2rem);
}
}
#media screen and (max-width: 32rem){
.col{
width: 100%;
margin: 0 0 2rem 0;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- CSS only -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<div class="col-sm-6 col-md-3 col-lg-3 p-2 col-6" ontouchstart="this.classList.toggle('hover');">
<div class="container">
<a href="viewmovie.php?series=<?php echo $id; ?>&episode=<?php echo $id_ep ?>">
<div class="front" style="background-image: url(../../src/upload/posts/<?php echo $img; ?>)" >
<div class="inner">
<h5><?php echo "$name"; ?></h5>
<h6>خوله‌ک <?php echo "$time"; ?> </h6>
<p></p>
<h6>IMDb: <?php echo $rate ?></h6>
<h6 class="fa fa-eye"> <?php echo "$views"; ?> </h6>
<span> </span>
</div>
</div>
<div class="back">
<div class="inner">
<p><?php echo "$description"; ?></p>
</div>
</div>
</a>
</div>
<center><a target="_blank" href= "<?php echo $trailer2 ?>"> <button type="button" class="btn btn-danger btn-sm m-2"><span class="fa fa-play">ترایله‌ر</button></span></a></center>
</div>

/* import font */
#import url('https://fonts.googleapis.com/css?family=Raleway&display=swap');
*{
margin: 0;
padding: 0;
}
body{
margin: 0;
padding: 0;
background: #f1f1f1;
font-family: "Raleway", sans-serif;
text-align: center;
}
header{
margin: 0;
}
a, li{
list-style: none;
text-decoration: none;
}
nav{
text-align: center;
padding-top: 15px;
padding-bottom: 15px;
background: white;
width: 100%;
}
.nav-link + .nav-link{
margin-left: 30px;
}
nav ul li + nav ul li{
margin-right: 30px;
}
nav ul li{
display: inline-block;
}
.products{
padding: 30px 50px 100px 50px ;
}
.card{
max-width: 20%;
background: #ffffff;
padding: 10px;
border-radius: 5px;
text-align: right; display: inline-block;
margin-left: 20px;
margin-top: 30px;
animation: rotation 1s ease-in-out ;
}
#keyframes rotation {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(359deg);
}
}
.card-body div{
margin-top: 10px;
}
.card-footer button{
margin-top: 20px;
background: #fb727c;
border-radius: 5px;
outline: none;
border: none;
color: white;
margin-bottom: 5px;
}
.product-name{
text-align: left;
font-size: 18px;
font-family: "Raleway Medium", sans-serif;
}
.product-price{
text-align: left;
font-size: 22px;
font-family: "Raleway Medium", sans-serif;
}
button{
cursor: pointer;
font-family: "Raleway SemiBold", sans-serif;
font-size: 16px;
padding: 8px 25px 8px 25px;
transition: 0.2s ease-in-out;
}
button:hover{
box-shadow: 0 5px 10px rgba(239, 60, 73, 0.5);
transition: 0.2s ease-in-out;
background: rgb(239, 60, 73);
}
img{
max-width: 100%;
}
/* media queries */
#media (max-width: 768px) {
.products{
padding: 30px 20px 30px 20px;
}
.card{
max-width: 40%;
display: inline-block;
}
.card {
margin-left: 0;
margin-top: 30px;
}
}
<body>
<header>
<nav>
<ul>
<li class="nav-link"><a class="nav-item" href="">Home</a></li>
<li class="nav-link"><a class="nav-item" href="">About</a></li>
<li class="nav-link"><a class="nav-item" href="">Service</a></li>
<li class="nav-link"><a class="nav-item" href="">Contact</a></li>
</ul>
</nav>
</header>
<main>
<div class="products">
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
<div class="card">
<div class="card-header">
<div class="product-img">
<img src="https://www.nowfoods.com/sites/default/files/styles/home_site_sections/public/beauty-health-catagory-homepage_0.png?itok=wSmkgxgp" alt="">
</div>
</div>
<div class="card-body">
<div class="product-details">
<div class="product-name">Short denim dungarees</div>
</div>
<div class="product-price">
₹1,900
</div>
</div>
<div class="card-footer">
<button>Add to Cart</button>
</div>
</div>
</div>
</main>
</body>

Related

Avoid blurring on a child item when hovering a blurred div element / Bootstrap5.2

Pls I would need help to avoid having a blur effect on my child element "text-block" when the mouse is hovering the card element. The card element should completely have a blur effect when hovering with the mouse & display the text block over it.
I tried a lot of options that don't work throught the proposed solutions by the community. Thks a lot.
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<div class="col">
<div class="card shadow-sm">
<div class="container my-2">
<img src="./images/mnemba_view.JPG" class="w-100 w-sm-120 preview"/>
<div class="text-block">Click to read more</div>
</div> `
.card {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.preview {
position: relative;
}
.text-block {
position: absolute;
opacity: 0;
z-index: 1;
bottom: 0;
top: 50%;
left: 50%;
block-size: 50px;
inline-size: 200px;
padding: 10px 10px;
background-color: rgb(189, 113, 20);
color: white;
border-radius: 10px;
}
.card:hover .text-block{
opacity: 1;
transition: opacity 0.5s ease-in-out;
}
.card:not(hover) .text-block {
transition: 0.4s;
}
.card:hover {
filter: blur(2px);
cursor: pointer;
}
I eventually found the solution.
Here's the solution:
.text-block {
position: absolute;
opacity: 0;
bottom: 0;
top: 50%;
left: 50%;
block-size: 50px;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
inline-size: 200px;
background-color: rgb(189, 113, 20);
color: white;
border-radius: 10px;
pointer-events: none;
text-align: center;
}
<div class="album py-5">
<div class="container">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
<div class="col">
<div class="card shadow-sm">
<div class="card-header fw-bold" style="background-color:#b76800a9">Africa</div>
<div class="preview">
<img src="./images/mnemba_view.JPG" alt="Ile de Mnemba" class="w-100 h-sm-200 w-sm-120 align-item-center justify-content-center"/>
<button class="text-block">Click to read more</button>
</div>

CSS - Incorrect overlpapping - 3D Perspective

I'm experimenting with CSS perspective to flip cards with a 3D effect, however when the right-most cards flip they are incorrectly overlapping. I have attempted to use Z-Index (which I am aware requires a positioning of anything but "static") however this has had no effect. Any help would be greatful. The project is in the following CodePen:
https://codepen.io/mikrayall/pen/WNzBxEw
HTML:
<div class="card">
<div id="cardContents" class="cardContents1">
<div class="cardFront"><h2>A</h2></div>
<div class="cardBack"><p>Once there was a dog...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents2">
<div class="cardFront"><h2>STORY</h2></div>
<div class="cardBack"><p>A dog and a frog...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents3">
<div class="cardFront"><h2>ABOUT</h2></div>
<div class="cardBack"><p>The frog sat on the dog...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents2">
<div class="cardFront"><h2>A</h2></div>
<div class="cardBack"><p>Like the dog was a log...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents1">
<div class="cardFront"><h2>DOG</h2></div>
<div class="cardBack"><p>The dog ate the frog...!</p></div>
</div>
</div>
CSS:
*, *::before, *::after{
margin: 0;
box-sizing: border-box;
}
body{
height:100vh;
display:flex;
justify-content:center;
align-items: center;
font-family: 'calibri';
perspective:700px;
background-image: linear-gradient(180deg, #000, #666)
}
.card{
margin: auto 10px;
width:6em;
border: 1px solid white;
border-radius:0.3em;
perspective: 700px;
transform: rotateX(45deg);
transform-style: preserve-3d;
transform-origin:bottom;
}
#cardContents{
position: relative;
width: 6em;
height: 8em;
border-radius:0.3em;
text-align: center;
transition: transform 0.5s;
transform-style: preserve-3d;
transform-origin:bottom;
}
.cardFront, .cardBack{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 0.3em;
backface-visibility: hidden;
transform-style: preserve-3d;
display:grid;
align-content: center;
}
.cardFront{
background-color: pink;
border:0.2em solid white;
}
.cardBack{
transform: rotateY(180deg);
background: lightblue;
border:0.2em solid white;
}
.card:hover #cardContents{
transform: rotateX(-37deg) translateZ(100px) rotateY(180deg) translateY(-40px);
}
I've attempted to apply Z-Index to the various elements (.cardBack, .cardFront, .cardContents).
Any help gatefully appreciated. Thank you.
add z-index to the hovered card only
.card:hover {
z-index:1;
}
Full code
*, *::before, *::after{
margin: 0;
box-sizing: border-box;
}
body{
height:100vh;
display:flex;
justify-content:center;
align-items: center;
font-family: 'calibri';
perspective:700px;
background-image: linear-gradient(180deg, #000, #666)
}
.card{
margin: auto 10px;
width:6em;
border: 1px solid white;
border-radius:0.3em;
perspective: 700px;
transform: rotateX(45deg);
transform-style: preserve-3d;
transform-origin:bottom;
}
#cardContents{
position: relative;
width: 6em;
height: 8em;
border-radius:0.3em;
text-align: center;
transition: transform 0.5s;
transform-style: preserve-3d;
transform-origin:bottom;
}
.cardFront, .cardBack{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-radius: 0.3em;
backface-visibility: hidden;
transform-style: preserve-3d;
display:grid;
align-content: center;
}
.cardFront{
background-color: pink;
border:0.2em solid white;
}
.cardBack{
transform: rotateY(180deg);
background: lightblue;
border:0.2em solid white;
}
.card:hover {
z-index:1;
}
.card:hover #cardContents{
transform: rotateX(-37deg) translateZ(100px) rotateY(180deg) translateY(-40px);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css.css">
<title>Document</title>
</head>
<body>
<div class="card">
<div id="cardContents" class="cardContents1">
<div class="cardFront"><h2>A</h2></div>
<div class="cardBack"><p>Once there was a dog...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents2">
<div class="cardFront"><h2>STORY</h2></div>
<div class="cardBack"><p>A dog and a frog...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents3">
<div class="cardFront"><h2>ABOUT</h2></div>
<div class="cardBack"><p>The frog sat on the dog...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents2">
<div class="cardFront"><h2>A</h2></div>
<div class="cardBack"><p>Like the dog was a log...</p></div>
</div>
</div>
<div class="card">
<div id="cardContents" class="cardContents1">
<div class="cardFront"><h2>DOG</h2></div>
<div class="cardBack"><p>The dog ate the frog...!</p></div>
</div>
</div>
</body>
</html>

turning transition, with !important value, off on responsive

So I got this code for a section in my page that uses a "!important" value on the css to make it work properly but I feel like it might be affecting the responsive side of it. I currently got the section to look properly on small devices but once I click(or hover) anywhere on the section, the section once again goes weird and I can't help but to think that the .projects-others:hover {width: 60% !important;} is behind it since it won't let me turn the transition off. How can I take it off for small devices but keep it on regular size? I've even tried putting the !important value on the transition queries but still no luck.
/*project section starts*/
.projects {
overflow: hidden;
height: 27em;
margin-top: 50px;
border: ;
}
.projects a {
cursor: default;
}
.box {
box-sizing: border-box;
box-shadow: 1.1px 1.2px #595959;
}
.projects h1 {
font-size: 4.40em;
text-align: center;
text-shadow: 0 3px 3px rgba(0, 0, 0, 0.9);
font-family: 'Dancing Script', cursive;
line-height: 80px;
padding-top: 2px;
}
.projects-others,
.projects-coding {
width: 50%;
-moz-transition: width .3s;
-webkit-transition: width .3s;
-o-transition: width .3s;
transition: width .3s;
height: 27em;
padding: 1em;
box-sizing: border-box;
}
.projects-others {
float: right;
background: #00004d;
background-size: cover;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
}
.projects-coding {
background: white;
border-right: ;
}
.projects:hover .projects-others {
width: 40%;
}
.projects-coding:hover {
width: 60%;
}
/*the code that I think is causing the problem*/
.projects-others:hover {
width: 60% !important;
}
.projects-others:hover~.projects-coding {
width: 40%;
}
/*courosel section starts*/
.slideshow-container {
max-width: 1000px;
height: 7.5em;
position: relative;
margin: 7.5px auto;
}
.mySlides,
.mySlides2 {
display: none;
}
.project-text {
display: flex;
width: 100%;
justify-content: center;
align-items: center;
font-family: 'Inknut Antiqua', serif;
}
.slideshow-img {
width: 17.4rem;
height: 10.5rem;
border-radius: 5px;
box-shadow: 2.5px 2.5px 2px rgba(0, 0, 0, 0.7);
-webkit-transition: display 1s;
transition: all 1s;
}
.slide-hover-p {
display: none;
}
.slideshow-img:hover+.slide-hover-p {
display: block;
}
.fade-car {
-moz-animation-name: fade-car;
-webkit-animation-name: fade-car;
-moz-animation-duration: 2.5s;
-webkit-animation-duration: 2.5s;
}
.previous,
.nexxt {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: ;
font-weight: bold;
font-size: 28px;
transition: 0.85s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
.nexxt {
right: 0;
border-radius: 3px 0 0 3px;
}
.previous:hover,
.nexxt:hover {
cursor: pointer;
}
#p-others:hover,
#n-others:hover {
background-color: white;
color: #00004d;
}
#p-coding:hover,
#n-coding:hover {
background-color: #00004d;
color: white;
}
/*courosel media queries*/
#-webkit-keyframes fade-car {
from {
opacity: 0.4
}
to {
opacity: 1
}
}
#keyframes fade-car {
from {
opacity: 0.4
}
to {
opacity: 1
}
}
#media only screen and (max-width: 300px) {
.previous,
.nexxt,
.text {
font-size: 11px
}
}
#coding-github-btn {
font-size: 1.35em;
font-weight: 400;
background: #00004d;
border: 1px solid #00004d;
transition: all 0.9s;
cursor: pointer;
}
#coding-github-btn:hover,
#coding-github-btn:focus {
background: white;
border: 1px solid #00004d;
color: #00004d;
}
#others-etsy-btn {
font-size: 1.175em;
font-weight: 500;
background: #ffdb4d;
border: 1px solid #ffdb4d;
transition: all 0.6s;
color: #00004d;
cursor: pointer;
}
#others-etsy-btn:hover,
#others-etsy-btn:focus {
opacity: 0.7;
}
/*media queries for section*/
#media only screen and (max-width: 575px) {
.projects {
height: auto;
-moz-transition: none;
-webkit-transition: none;
-o-transition: none;
transition: none;
}
.projects a {
transition: none;
}
.projects-others, .projects-coding {
-moz-transition: none;
-webkit-transition: none;
-o-transition: none;
transition: none;
height: auto;
width: 100%;
max-width: 100%;
flex: 100%;
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans|Inknut+Antiqua|Dancing+Script|Courgette&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"><!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="profile-css/profile-stylesheet.css" type="text/css" />
<link rel="stylesheet" href="profile-css/mq-stylesheet.css" type="text/css" />
</head>
<body>
<!--project section headings-->
<div class="projects">
<a>
<div class="box projects-others" style="color: #ffdb4d;">
<h1 style="color: #ffdb4d;">Projects :<br> Others</h1>
<!--slider starts-->
<div class="slideshow-container">
<div class="mySlides fade-car">
<div class="project-text">
<img src="images/colorado_view2.jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<a id="p-others" class="previous" onclick="plusSlides(-1)">❮</a>
<a id="n-others" class="nexxt" onclick="plusSlides(1)">❯</a>
<span class="dot" onclick="currentSlide(1)"></span>
<span class="dot" onclick="currentSlide(2)"></span>
<span class="dot" onclick="currentSlide(3)"></span>
</div>
<!--slideshow ends-->
<br><br>
<div class="w-100 text-center">
<a id="others-etsy-btn" href="#" class="btn" role="button">My Etsy Store <span class="fa fa-etsy"></span></a>
</div>
</div>
</a>
<a>
<div class="box projects-coding" style="color:#00004d;">
<h1 style="color:#00004d;">Projects :<br> Coding</h1>
<!--second slider starts-->
<div class="slideshow-container">
<div class="mySlides2 fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides2 fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<div class="mySlides2 fade-car">
<div class="project-text">
<img src="images/global (35).jpg" class="slideshow-img img-fluid" alt="global6" />
<p class="slide-hover-p"><i>(My Profile Webpage)</i></p>
</div>
</div>
<a id="p-coding" class="previous" onclick="plusSlides2(-1)">❮</a>
<a id="n-coding" class="nexxt" onclick="plusSlides2(1)">❯</a>
<span class="dot2" onclick="currentSlide2(1)"></span>
<span class="dot2" onclick="currentSlide2(2)"></span>
<span class="dot2" onclick="currentSlide2(3)"></span>
</div>
<!--slider ends-->
<br><br>
<div class="w-100 text-center">
<a id="coding-github-btn" href="#" class="btn" role="button">My Repositories <span class="fa fa-github"></span></a>
</div>
</div>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script><!-- Popper JS -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script><!-- Latest compiled bootstrap JavaScript -->
</body>
</html>
Placing a media query at the bottom of your css file with the same class and using important as well would definitely fix this.

How can I make this overlay cover the whole thumbnail

So I would like to cover the whole thumbnail when hovering over, so that the overlay content fills the whole image, 100% by 100%. So the overlay should cover only image(whole size of it), not more than that.
Here's the pen to demonstrate the current state: http://codepen.io/anon/pen/JbJgoe
.about__images {
max-width: 800px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
margin-right: 20px;
}
.about .about__inner {
position: relative;
overflow: hidden;
}
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
}
.about .about__inner:hover .about__inner--overlay {
opacity: 1;
}
<div class="container about">
<div class="about__images">
<div class="row">
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="" class="hideonhover">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
</div>
</div>
</div>
You are close to it. Just a small modification in structure and a few lines in css:
HTML:
<div class="col-md-4">
<div class="about__inner">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="" class="hideonhover">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
CSS:
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
position: absolute;
top:0;
width:100%;
height:100%;
}
.about__inner{
position:relative;
}
.about__inner--overlay{
color:#fff;
}
Codepen: http://codepen.io/swapnaranjitanayak/pen/oYwKLO
You need to use absolute positionning and size the box. You may use coordonates to size the box so it fits any size since you already set the parent in relative positionning..
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
top:0;
left:15px;
right:15px;
bottom:0;
color:white;
position:absolute
}
.about__images {
max-width: 800px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
padding-right: 20px;
}
.about .about__inner {
position: relative;
overflow: hidden;
}
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
top:0;
left:15px;
right:35px;
bottom:0;
color:white;
position:absolute
}
.about .about__inner:hover .about__inner--overlay {
opacity: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="container about">
<div class="about__images">
<div class="row">
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="" class="hideonhover">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=38&txt=400%C3%97300&w=400&h=300" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>lorem</p>
</div>
</div>
</div>
</div>
</div>
Try this:
.about__inner {
padding: 0px; //for full frame image
}
.about__inner img {
max-width: 100%;
max-height: 100%;
object-fit: cover; //force image display as cover, no scale
}
.about .about__inner .about__inner--overlay {
position: absolute; //You need it to arrange the div.
top: 0px;
left:0px;
width: 100%;
height: 100%;
}
Try this:
.about__images {
max-width: 800px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
margin-right: 20px;
}
.about .about__inner {
position: relative;
overflow: hidden;
}
.about .about__inner .about__inner--overlay {
background: rgba(0, 0, 0, .75);
text-align: center;
padding: 45px 0 66px 0;
opacity: 0;
transition: opacity .25s ease;
}
.about .about__inner:hover .about__inner--overlay {
opacity: 1;
position: relative;
height: 185px;
top: -185px;
}

Bootstrap grid alignment not working

I have a set of three "cards" (but not using the bootstrap card class) that I need to align horizontally and center on the page. I am setting the outer div to a full width, and trying to give each of the three .info-card classes equal .col-lg-4 width. This is still keeping the cards floated left(removing the left float from the .flip-card class aligns the cards vertically. How can I get the columns applied correctly here?
<div class="container">
<div class="flip-cards col-lg-12">
<div class="info-card col-lg-4">
<div class="front">
<h3>Header</h3>
</div>
<div class="back">
<p>Title</p>
<h6>lorem ipsum</h6>
</div>
</div>
<div class="info-card col-lg-4">
<div class="front">
<h3>Header</h3>
</div>
<div class="back">
<p>Title</p>
<h6>lorem ipsum</h6>
</div>
</div>
<div class="info-card col-lg-4">
<div class="front">
<h3>Header</h3>
</div>
<div class="back">
<p>Title</p>
<h6>lorem ipsum</h6>
</div>
</div>
</div>
</div>
CSS
.container{
background-color: #eee;
}
.flip-cards .info-card {
float: left;
margin: 2% 1% 0% 1%;
padding: 5% 0% 5% 0%;
position: relative;
-webkit-perspective: 600px;
}
.flip-cards .info-card:hover .back {
-webkit-transform: rotateY(0);
}
.flip-cards .info-card:hover .front {
-webkit-transform: rotateY(180deg);
}
.flip-cards .info-card .front, .flip-cards .info-card .back {
transition: -webkit-transform 1s;
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
}
.flip-cards .info-card .front {
background-color: #fff;
overflow: hidden;
width: 200px;
height: 170px;
position: absolute;
opacity: .5;
}
.flip-cards .info-card .front h3 {
text-decoration: underline;
padding: 10px;
text-align: left;
color: #6633cc;
}
.flip-cards .info-card .back {
background-color: #6633cc;
width: 200px;
height: 170px;
-webkit-transform: rotateY(-180deg);
}
.flip-cards .info-card .back p {
color: #fff;
padding: 7px 0px 0px 10px;
font-size: 10px;
}
.flip-cards .info-card .back h6 {
font-weight: 400;
color: #fff;
position: absolute;
text-align: left;
padding: 0px 10px 10px 10px;
bottom: 0;
}
.flip-cards .info-card .back h6 a {
color: #fff;
text-decoration: underline;
}
#media (max-width: 400) {
.flip-cards {
margin-left: -3%;
}
.card-outer-wrapper {
height: 260px;
margin-bottom: 40px;
max-width: 100vw;
overflow-x: scroll;
overflow-y: hidden;
position: relative;
}
.card-outer-wrapper .card-wrapper {
overflow-x: scroll;
width: 200%;
}
}
JSFIDDLE: https://jsfiddle.net/sxLodk6r/
Let's redo it again.
This time I'll list all code which need to be fixed, and at last I'll paste all final html and css code for your convenient.
Add grid below <div class="row"> in bootstrap.
<div class="container">
<div class="row"> <!-- Add This -->
<div class="flip-cards col-lg-12 ">
...
</div>
</div> <!-- Add This -->
</div>
Don't add any class which contain padding and margin with grid class in the same level.
<div class="col-lg-4">
<div class="info-card "> <!-- Separate this class -->
...
</div>
</div>
It would be better to avoid percent value in margin/padding top/bottom and it is easier for you to define the position of .back later in list 7.
.flip-cards .info-card {
margin: 20px 10px 0 10px;
padding: 10px 0 10px 0;
}
If you want to align .info-card center, replace float:left with display:inline-block in .info-card and add .text-center with .col-lg-4
.flip-cards .info-card {
display: inline-block;
float: left; /* Remove This! */
}
<div class="col-lg-4 text-center">
<div class="info-card ">
...
</div>
</div>
Don't use overflow:hidden in .front, instead, remove the margin-top in h3.
.flip-cards .info-card .front { {
overflow: hidden; /* Remove This */
}
.flip-cards .info-card .front h3 {
margin-top: 0px;
}
</div>
Remove positon:absolute in .front.
.flip-cards .info-card .front {
position: absolute; /* Remove This! */
}
Add position:absolute and top:10px in .back.
.flip-cards .info-card .back {
background-color: #6633cc;
width: 200px;
height: 170px;
position: absolute;
top:10px;
-webkit-transform: rotateY(-180deg);
}
My Html code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="flip-cards col-lg-12 ">
<div class="col-lg-4 text-center">
<div class="info-card ">
<div class="front">
<h3>Header</h3>
</div>
<div class="back">
<p>Title</p>
<h6>lorem ipsum</h6>
</div>
</div>
</div>
<div class="col-lg-4 text-center">
<div class="info-card ">
<div class="front">
<h3>Header</h3>
</div>
<div class="back">
<p>Title</p>
<h6>lorem ipsum</h6>
</div>
</div>
</div>
<div class="col-lg-4 text-center">
<div class="info-card ">
<div class="front">
<h3>Header</h3>
</div>
<div class="back">
<p>Title</p>
<h6>lorem ipsum</h6>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
My Css code
.container{
background-color: #eee;
}
.flip-cards .info-card {
display: inline-block;
margin: 20px 10px 0 10px;
padding: 10px 0 10px 0;
position: relative;
-webkit-perspective: 600px;
}
.flip-cards .info-card:hover .back {
-webkit-transform: rotateY(0);
}
.flip-cards .info-card:hover .front {
-webkit-transform: rotateY(180deg);
}
.flip-cards .info-card .front, .flip-cards .info-card .back {
transition: -webkit-transform 1s;
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
}
.flip-cards .info-card .front {
background-color: #fff;
width: 200px;
height: 170px;
opacity: .5;
}
.flip-cards .info-card .front h3 {
text-decoration: underline;
padding: 10px;
text-align: left;
color: #6633cc;
margin-top: 0px;
}
.flip-cards .info-card .back {
background-color: #6633cc;
width: 200px;
height: 170px;
position: absolute;
top:10px;
-webkit-transform: rotateY(-180deg);
}
.flip-cards .info-card .back p {
color: #fff;
padding: 7px 0px 0px 10px;
font-size: 10px;
}
.flip-cards .info-card .back h6 {
font-weight: 400;
color: #fff;
position: absolute;
text-align: left;
padding: 0px 10px 10px 10px;
bottom: 0;
}
.flip-cards .info-card .back h6 a {
color: #fff;
text-decoration: underline;
}
#media (max-width: 400) {
.flip-cards {
margin-left: -3%;
}
.card-outer-wrapper {
height: 260px;
margin-bottom: 40px;
max-width: 100vw;
overflow-x: scroll;
overflow-y: hidden;
position: relative;
}
.card-outer-wrapper .card-wrapper {
overflow-x: scroll;
width: 200%;
}
}

Resources