I have been trying to code a simple gallery in Bootstrap, however, there is an unnecessary gap that keeps on appearing again and again on the right side of the column. I am unable to understand the cause of this gap.
Here is the HTML Code:
<div class="row" id="r2">
<div class="col-md-12" id="heading">
<h1>| PROJECTS |</h1>
</div>
</div>
<div class="row no-gutters">
<div class="col-xs-12 col-sm-6 col-md-4">
<img src="img/9.jpg" style='width: 100%; object-fit: contain'>
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 left">
<img src="img/10.jpg" style='width: 100%; object-fit: contain'>
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 left">
<img src="img/11.jpg" style='width: 100%; object-fit: contain'>
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-xs-12 col-sm-6 col-md-4 left">
<img src="img/8.jpg" style='width: 100%; object-fit: contain'>
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 left">
<img src="img/7.jpg" style='width: 100%; object-fit: contain'>
<div class="overlay">
<div class="text">Hello World</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4 left">
<img src="img/8.jpg" style='width: 100%; object-fit: contain'>
<div class="overlay">
<div class="text">View More..</div>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="clear"></div>
Here is a screenshot of the webpage showing the gap:Right Side Gap
The CSS Code :
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0px;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: black;
}
.overlay:hover {
opacity: 0.8;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
#r2{
background:#2952a3;
margin:0;
}
Any sort of help would be really appreciated!
Related
My Images seems to be not aligning in a Horizontal Row, I Tried every method but not working :(
Output:
.img-size-square {
width: 100%;
height: auto;
max-width: 400px !important;
max-height: 400px !important;
}
.container-for-hover {
position: relative;
width: 50%;
}
.image-for-hover {
display: block;
width: 100%;
height: auto;
}
.overlay-for-hover {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #6633ff;
}
.container-for-hover:hover .overlay-for-hover {
opacity: 1;
}
.text-for-hover {
color: white;
font-weight: bold;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="row">
<div class="row">
<div class="d-flex col-12">
<div class="mx-auto">
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 1, Row 1</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 2, Row 1</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 3, Row 1</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="d-flex col-12">
<div class="mx-auto">
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 1, Row 2</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 2, Row 2</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 3, Row 2</div>
</div>
</div>
</div>
</div>
</div>
</div>
What I Tried:
I Tried everything on the Official Docs and on here -> W3 BS5 Docs, I Tried also flex-row, I'm also new to Web Developing Field.
Goal:
The container-for-image Div(s) should be Placed in a Horizontal Row in each row class div
just use flex on class mx-auto
.img-size-square {
width: 100%;
height: auto;
max-width: 400px !important;
max-height: 400px !important;
}
.container-for-hover {
position: relative;
width: 50%;
}
.image-for-hover {
display: block;
width: 100%;
height: auto;
}
.overlay-for-hover {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #6633ff;
}
.container-for-hover:hover .overlay-for-hover {
opacity: 1;
}
.text-for-hover {
color: white;
font-weight: bold;
font-size: 20px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.mx-auto{
display:flex;
margin:0 auto;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="row">
<div class="row">
<div class="d-flex col-12">
<div class="mx-auto">
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 1, Row 1</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 2, Row 1</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 3, Row 1</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="d-flex col-12">
<div class="mx-auto">
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 1, Row 2</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 2, Row 2</div>
</div>
</div>
<div class="container-for-hover img-size-square mb-2">
<img class="image-for-hover" src="http://jazzfu.000webhostapp.com/upload/placeholder-sq.webp">
<div class="overlay-for-hover">
<div class="text-for-hover">Some Content Here 3, Row 2</div>
</div>
</div>
</div>
</div>
</div>
</div>
You need to have the 3 children as direct children of the d-flex container, since that is the flex container. The way you have it, d-flex is trying to put only mx-auto into a row (resulting in a row of 1 div).
<div class="row">
<div class="row">
<div class="d-flex col-12 mx-auto">
<div class="container-for-hover img-size-square mb-2">
...
</div>
<div class="container-for-hover img-size-square mb-2">
...
</div>
<div class="container-for-hover img-size-square mb-2">
...
</div>
</div>
</div>
</div>
I divided a page into two columns. When I reduce the screen, is there any way to put everything in just one column?
At this moment, when I reduce the screen, the width of the cards decreases (as shown in the image). Is there a way to put all the cards in just one column (on mobile) in order to keep the width at 100%?
Is there a way to put everything in just one column and with a margin top between the elements?
Thanks.
Stackblitz - DEMO
Code
<div style="width: 100%; height: 100%; overflow-y: scroll; overflow-x: hidden;">
<div style="width: 100%; height: 85%">
<div class="modal-body row" style="overflow: auto; margin-top: 135px; height: 100%;">
<div class="col-md-6">
<div style="height: 700px;">
<div class="container">
</div>
<div class="row">
<div class="Upcard">
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row" style="height: 100%;">
<div class="col-6">
<div class="card cardBig" style="margin-left: 16px; margin-right: 16px; line-height: 1;">
<div class="card-header header">
<h1> It </h1>
</div>
<div class="card-body">
</div>
</div>
</div>
<div class="col-6">
<div class="card" style="margin-left: 8px; margin-right: 16px; line-height: 1;">
<div class="card-header header">
<h1> data </h1>
</div>
<div class="card-body">
</div>
</div>
<div class="card card-small" style="margin-left: 8px; margin-right: 16px; margin-top: 16px;">
<div class="card-header header">
<h1> T </h1>
</div>
<div class="card-body" style="overflow-y: auto; overflow-x: hidden;">
</div>
</div>
<div class="card card-small" style="margin-left: 8px; margin-right: 16px; margin-top: 16px;">
<div class="card-header header">
<h1> Att </h1>
</div>
<div class="card-body att" style="overflow-x: hidden; overflow-y: auto;">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Please try this snippet.
.card {
width: 100%;
height: 50%;
margin-bottom: 16px;
background: red 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 20px #BCBCCB47;
border-radius: 8px;
opacity: 1;
border: none;
}
.cardBig {
height: calc(100% - 16px);
}
.card-small {
height: 23%;
}
/* ---------------------------UPLOAD----------------------------------- */
.container {
width: 100%;
height: 100%;
padding: 2rem;
text-align: center;
border: dashed 4px blue;
position: relative;
margin: 0 auto;
border-radius: 16px;
display: flex;
justify-content: center;
align-items: center;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div style="width: 100%; height: 100%; overflow-y: scroll; overflow-x: hidden;">
<div style="width: 100%; height: 85%">
<div class="modal-body row" style="overflow: auto; margin-top: 135px; height: 100%;">
<div class="col-md-6 col-sm-12">
<div style="height: 700px;">
<div class="container">
</div>
<div class="row">
<div class="Upcard">
</div>
</div>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="row" style="height: 100%;">
<div class="col-md-6 col-sm-12">
<div class="card cardBig">
<div class="card-header header">
<h1> It </h1>
</div>
<div class="card-body">
</div>
</div>
</div>
<div class="col-md-6 col-sm-12">
<div class="card">
<div class="card-header header">
<h1> data </h1>
</div>
<div class="card-body">
</div>
</div>
<div class="card card-small">
<div class="card-header header">
<h1> T </h1>
</div>
<div class="card-body" style="overflow-y: auto; overflow-x: hidden;">
</div>
</div>
<div class="card card-small">
<div class="card-header header">
<h1> Att </h1>
</div>
<div class="card-body att" style="overflow-x: hidden; overflow-y: auto;">
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
<p>asdasdasdasdasdasdasdas</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Trying to create a responsive flip-card gallery using a code I came across here. Everything works great except for when I try to align the flip-cards next to each other (trying to create three cards per row) then they just disappear. I've tried using display: inline-block and a flex-grid, but can't figure out where i'm going wrong.
Thank you!
Here's the intial code:
HTML
<div class="container">
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="image1.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="metalcard.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="image3.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS:
.container {
margin: 0 auto;
max-width: 1200px;
padding: 0 1rem;
display: inline-block;
}
.card-container{
width: 25%; /* Adjust the target width*/
}
.flip-container {
position: relative;
perspective: 1000px;
}
/* flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
transform: rotateY(180deg);
}
.flip-container, .front, {
width: 100%;
height: 170px;
}
.flip-container,.back {
height: 190px;
width: 100%;
}
.flipper {
transition: 0.9s;
transform-style: preserve-3d;
position: relative;
}
.front, .back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
background: rgba(0,0,0,0.05);
z-index: 2;
/* for firefox 31 */
transform: rotateY(0deg);
}
/* back, initially hidden pane */
.back {
background: #00ccff;
transform: rotateY(180deg);
}
I tried your code in a jsfiddle and they were some parts of the html code missing and i fix the class .container and .card-container
Here you go
HTML
<div class="container">
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="image1.jpg" style="height: 100%;"> </div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="metalcard.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-container">
<div class="row">
<div class="col">
<div class="flip-container">
<div class="flipper">
<div class="front">
<div class="inner"><img src="image3.jpg" style="height: 100%;"></div>
</div>
<div class="back">
<div class="inner">Back</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
.container {
width: 100%;
}
.card-container{
width: 25%; /* Adjust the target width*/
display: inline-block;
}
I am using CSS transform property scaleX for my animation. See CodePen. Unfortunately the red box on the left has no effects on hover and its not transforming like the other 3 ones. From my understanding, as the red box has no space on it's left that is why it cannot transform on hover. Is there any good solution for my problem?
HTML
<div class="container-fluid mt-3">
<div class="row">
<div class="col-sm-3">
<div class="img-holder">
<div class="image image1"></div>
</div>
</div>
<div class="col-sm-3">
<div class="img-holder">
<div class="image image2"></div>
</div>
</div>
<div class="col-sm-3">
<div class="img-holder">
<div class="image image3"></div>
</div>
</div>
<div class="col-sm-3">
<div class="img-holder">
<div class="image image4"></div>
</div>
</div>
</div>
</div>
You can also reset z-index on :hover and eventually transform-origin for the first and last element:
.image1 {
background-color: red;
}
.image2 {
background-color: green;
}
.image3 {
background-color: blue;
}
.image4 {
background-color: pink;
}
.image {
height: 15vw;
}
.img-holder {
position: relative;
width: 100%;
}
.img-holder .image {
width: 100%;
position: relative;
z-index: 5;
transition: all 0.5s ease;
}
.img-holder .image:hover {
transform: scaleX(2);
z-index: 10;
}
.col-sm-3:first-of-type :hover .image {
transform-origin: top left;
}
.col-sm-3:last-of-type :hover .image {
transform-origin: top right;
}
.col-sm-3 {
padding: 0;
}
<div class="container-fluid mt-3">
<div class="row">
<div class="col-sm-3">
<div class="img-holder">
<div class="image image1"></div>
</div>
</div>
<div class="col-sm-3">
<div class="img-holder">
<div class="image image2"></div>
</div>
</div>
<div class="col-sm-3">
<div class="img-holder">
<div class="image image3"></div>
</div>
</div>
<div class="col-sm-3">
<div class="img-holder">
<div class="image image4"></div>
</div>
</div>
</div>
</div>
https://codepen.io/gc-nomade/pen/dzvypQ
there's some problems with responsive grid system to me.
http://imageshack.com/a/img537/9687/4H48G0.jpg
http://imageshack.com/a/img539/8265/ANvr0Y.jpg - problem is here
My source code:
CSS
<style type="text/css">
.wrapper {
height: 100%;
text-align: center;
margin: 0 auto;
}
img { max-width:100% !important;
height:auto;
display:block;
}
.text {
color: #fff;
text-shadow:0px 2px 10px #000;
height: 100%;
left: 0;
position: absolute;
text-align: center;
top: 0;
font-size: 22px;
width: 100%;}
.box {
border: 1px dashed #000;
overflow: hidden;
position: relative;
}
.tb_floater {
font-size: 1.5em;
margin-top: 20%;
padding-top: 10%;
}
.box.tall {
height: 300px;
}
.box.tall > a > img {
height: auto;
}
</style>
HTML
<div class="wrapper">
<div class="container">
<div class="row">
<div class="col-md-4 box tall">
<a href="#">
<img src="http://www.websailer.com/wp-content/uploads/2013/07/www_image.jpg">
</a>
<div class="text tall">
<div class="tb_floater">
<p>Loren ipsum shit amet<br/>Loren ipsum</p>
</div>
</div>
</div>
<div class="col-xs-6 col-md-6 box" style="height:150px;">.col-xs-6 .col-md-6</div>
<div class="col-xs-6 col-md-2 box" style="height:150px;">.col-xs-6 .col-md-2</div>
<div class="col-xs-6 col-md-2 box" style="height:150px;">.col-xs-6 .col-md-2</div>
<div class="col-xs-6 col-md-6 box" style="height:150px;">.col-xs-6 .col-md-6</div>
</div>
<div class="row">
<div class="pull-right col-xs-6 col-md-4 box tall">
<a href="#">
<img src="http://www.websailer.com/wp-content/uploads/2013/07/www_image.jpg">
</a>
<div class="text tall">
<div class="tb_floater">
<p>Loren ipsum shit amet<br/>Loren ipsum</p>
</div>
</div>
</div>
<div class="col-xs-6 col-md-2 box" style="height:150px;">.col-xs-6 .col-md-6</div>
<div class="col-xs-6 col-md-6 box" style="height:150px;">.col-xs-6 .col-md-2</div>
<div class="col-xs-6 col-md-2 box" style="height:150px;">.col-xs-6 .col-md-6</div>
<div class="col-xs-6 col-md-6 box" style="height:150px;">.col-xs-6 .col-md-2</div>
</div>
That empty field is problem when i resize the browser, any solution ?