In the following code I inserted 5 images but I cannot put all of them in a single row and eliminate the spacing between them.
<section class="images">
<div class="row">
<div class="col-lg-3">
<img class="img-responsive" src="images1.jpg" alt="images1" max-width="400px" max-height="95px" width="auto" height="auto">
</div>
<div class="col-lg-3">
<img class="img-responsive" src="images2.jpg" alt="images2" max-width="230px" max-height="95px" width="auto" height="auto">
</div>
<div class="col-lg-3">
<img class="img-responsive" src="images3.jpg" alt="images3" max-width="230px" max-height="95px" width="auto" height="auto">
</div>
<div class="col-lg-3">
<img class="img-responsive" src="images4.jpg" alt="images4" max-width="230px" max-height="95px" width="auto" height="auto">
</div>
<div class="col-lg-3">
<img class="img-responsive" src="images5.jpg" alt="images1">
</div>
</div>
</section>
How can I put the 5 images together and eliminate the space between the images?
Bootstrap column divs come with padding. Eliminate them:
.row div {padding:0;}
Let's divide the row into one wide image and four narrow images.
1 x 400px + 4 x 230px = 1320px
400px / 1320px = 10 / 33
230px / 1320px = 23 / 132
Oops, such parts are not suitable for the layout based on 12 columns. Because each of the columns has to
1320px / 12 = 110px
I suggest a little change the width of images:
440px = 4 x 110px
220px = 2 x 110px
The image 440 pixels wide will take 4 of 12 columns. The image 220 pixels wide will take 2 of 12 columns.
Remove the clearance between the columns:
.images {
padding: 0 15px;
}
.images .col-lg-2,
.images .col-lg-4 {
padding: 0;
}
Bootstrap determines img-responsive like so:
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
Therefore, we write
width="100%"
instead of
max-width="...px" max-height="95px" width="auto" height="auto"
Check the result:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
.images {
padding: 0 15px;
}
.images .col-lg-2,
.images .col-lg-4 {
padding: 0;
}
<section class="images">
<div class="row">
<div class="col-lg-4">
<img class="img-responsive" src="http://placehold.it/440x95" alt="images1" width="100%">
</div>
<div class="col-lg-2">
<img class="img-responsive" src="http://placehold.it/220x95/ddd" alt="images2" width="100%">
</div>
<div class="col-lg-2">
<img class="img-responsive" src="http://placehold.it/220x95" alt="images3" width="100%">
</div>
<div class="col-lg-2">
<img class="img-responsive" src="http://placehold.it/220x95/ddd" alt="images4" width="100%">
</div>
<div class="col-lg-2">
<img class="img-responsive" src="http://placehold.it/220x95" alt="images5" width="100%">
</div>
</div>
</section>
You can also simplify things!
Put everything in a col-lg-12, then add your images as elements of an inline-list. If you dont need columns for each image, an inline list should work just fine.
You then only have to adjust the margin/padding of your li img elements to determine how much space you want between them.
Much simpler, no?
Ideally, a full width is 100%.Therefore,if you need 5 images you simply divide 100 by 5 which will give 20%.
Check the html code:
<footer class="images">
<div class="row">
<div class="col-lg-2">
<img class="img-responsive" id="responsive" src="Dollarphotoclub_79081264-copy.jpg" alt="images1">
</div>
<div class="col-lg-2">
<img class="img-responsive" id="responsive" src="beds.jpg" alt="images1">
</div>
<div class="col-lg-2">
<img class="img-responsive" id="responsive" src="bed-cream.jpg" alt="images1">
</div>
<div class="col-lg-2">
<img class="img-responsive" id="responsive" src="soaps.jpg" alt="images1">
</div>
<div class="col-lg-2">
<img class="img-responsive" id="responsive" src="Dollarphotoclub_79081264-copy.jpg" alt="cake2">
</div>
</div>
</footer>
The css code will be as it follows:
.masterfooter .col-lg-2 {
width: 20%;
float: left;
}
Related
I have a Bootstrap 5 carousel with captions. Is it possible to add any class to the div containing the carousel-item or the carousel-caption to put the captions in the centre of the slide? Or I still need to use CSS as in older versions (below)? I tried align-middle and similar classes but without success.
Eg. Old solution from Fiddle:
.carousel-caption {
top: 0;
bottom: auto;
}
Can't really find a good combination of just using utility class to achieve what you want, but able to find a minimum way where still need to define a manual class :
.carousel-caption {
transform: translateY(50%);
}
and then add bottom-50 to carousel-caption. Since so it could rather just write
.carousel-caption {
transform: translateY(50%);
bottom: 50% !important;
}
LOL :)
#carouselExampleCaptions {
width: 600px;
height: 400px;
}
.carousel-caption {
transform: translateY(50%);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<div id="carouselExampleCaptions" class="carousel slide">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://rb.gy/18mzdx" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block bottom-50">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="https://rb.gy/18mzdx" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block bottom-50">
<h5>Second slide label</h5>
<p>Some representative placeholder content for the second slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="https://rb.gy/18mzdx" class="d-block w-100" alt="...">
<div class="carousel-caption d-none d-md-block bottom-50">
<h5>Third slide label</h5>
<p>Some representative placeholder content for the third slide.</p>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" 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="#carouselExampleCaptions" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
Created a swipe with thumbs. When I click on thumbs, it scrolls to the right with incomprehensible logic. I cannot understand what this may be connected with, I am trying to solve this problem for the second day, nothing comes out. Is it possible to somehow disable this option so that you can remove this scroll when clicked?
const productThumbs = new Swiper(".swiper-thumbs", {
spaceBetween: 30,
loop: true,
slidesPerView: 6,
loopedSlides: 7,
});
const productCarousel = new Swiper(".swiper-content", {
effect: 'fade',
fadeEffect: {
crossFade: true
},
touchRatio: 0,
thumbs: {
swiper: productThumbs,
}
});
.swiper-slide{
background: gray;
}
.swiper-thumbs .swiper-slide{
height: 300px;
}
.swiper-content{
margin-top: 30px;
}
.swiper-thumbs .swiper-slide{
display: flex;
flex-direction: column;
}
.swiper-content .swiper-slide{
height: 250px;
background: black;
color: white;
font-size: 72px;
}
<link href="https://unpkg.com/swiper/swiper-bundle.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
<div class="swiper-container swiper-thumbs">
<div class="swiper-wrapper">
<div class="swiper-slide">
<span class="slider-title">01</span>
<img src='https://i.ibb.co/Tq5Hvp8/1.png'>
<span class="slider-desc">Windows Server</span>
</div>
<div class="swiper-slide">
<span class="slider-title">02</span>
<img src='https://i.ibb.co/Tq5Hvp8/1.png'>
<span class="slider-desc">Windows Server</span>
</div>
<div class="swiper-slide">
<span class="slider-title">03</span>
<img src='https://i.ibb.co/Tq5Hvp8/1.png'>
<span class="slider-desc">Windows Server</span>
</div>
<div class="swiper-slide">
<span class="slider-title">04</span>
<img src='https://i.ibb.co/Tq5Hvp8/1.png'>
<span class="slider-desc">Windows Server</span>
</div>
<div class="swiper-slide">
<span class="slider-title">05</span>
<img src='https://i.ibb.co/Tq5Hvp8/1.png'>
<span class="slider-desc">Windows Server</span>
</div>
<div class="swiper-slide">
<span class="slider-title">06</span>
<img src='https://i.ibb.co/Tq5Hvp8/1.png'>
<span class="slider-desc">Windows Server</span>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<div class="swiper-container swiper-content">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
<div class="swiper-slide">Slide 6</div>
</div>
</div>
I tried to do this, but I just simply do not understand why this is happening
In the "thumbs" slider, you need to change the value "loop" to "false" or remove the key "loop" from "thumbs" slider.
You can see from the jfiddle link below what I'm trying to do and what the problem is. On a large screen I get a big space at the bottom which I can't remove. On the mobile I'd like each of the four images to take up the full screen but can't get it to work. Been trying to sort this for a day and I'm just going in circles now. Any help would be appreciated.
cheers
mike.
http://jsfiddle.net/batman13/wpnLjsuo/`
<div class="col-sm-6 fill50 hidden-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/sony_xperia-wallpaper-1920x1080.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive Big Screen </h2>
</div>
</div>
<div class="col-xs-12 fill100 visible-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/sony_xperia-wallpaper-1920x1080.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive mobile</h2>
</div>
</div>
<div class="col-sm-6 fill50 hidden-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/branding.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive2 Big Screen</h2>
</div>
</div>
<div class="col-xs-12 fill100 visible-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/branding.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive mobile</h2>
</div>
</div>
</div>
<div class="row" style="height:50%">
<div class="col-sm-12 fill100 hidden-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/apple_wooden-wallpaper-1920x1080.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive3 Big Screen</h2>
</div>
</div>
</div>
<div class="row" style="height:50%">
<div class="col-xs-12 fill100 visible-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/apple_wooden-wallpaper-1920x1080.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive3 Mobile</h2>
</div>
</div>
</div>
</div>
<div class="col-sm-6 fill50 hidden-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/background.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive Big Screen</h2>
</div>
</div>
<div class="col-xs-12 fill100 visible-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/background.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive Mobile</h2>
</div>
</div>
</div>`
White space issue is because of this:
<div class="row" style="height:50%">
<div class="col-sm-12 col-xs-12 fill100 visible-xs" style=
"background-image:url('http://ajsroofingsolutions.com/images/apple_wooden-wallpaper-1920x1080.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive3 Mobile3</h2>
</div>
</div>
</div>
You are setting the height of the row and hiding the content, so the row is still showing. You need to hide the row so move your .visible-xs and .hidden-xs to the rows. After that wanting the full viewport height on the mobile is going to require you to set up a media query and move your inline height styling out into a CSS file. For example:
<div class="row visible-xs" id="test">
<div class="col-sm-12 col-xs-12 fill100" style=
"background-image:url('http://ajsroofingsolutions.com/images/apple_wooden-wallpaper-1920x1080.jpg');">
<div class="carousel-caption">
<h2>Jonny 5 Alive3 Mobile3</h2>
</div>
</div>
</div>
CSS:
#test{
height: 50%;
}
#media(max-width: 500px){
#test{
height: 100vh;
}
}
I've got my stacked progress bars looking nice, with percentage labels on each, but I'm not sure how to solve when a percentage causes the bar to be too small for the label.
Setting a min-width works for non-stacked progress bars, but breaks stacked ones.
How can I fix this without hacking up bootstrap too much?
Example fiddle: http://jsfiddle.net/nimh/kx7hvxyz/
<div class="container-fluid">
<div class="row-fluid">
<div class="panel panel-default max-width">
<div class="panel-body">
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: 89.74%">
<div class="text-left">+89.74%</div>
</div>
<div class="progress-bar progress-bar-danger" style="width: 10.26%">
<div class="text-right">-10.26%</div>
</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: 10.26%">
<div class="text-left">+10.26%</div>
</div>
<div class="progress-bar progress-bar-danger" style="width: 89.74%">
<div class="text-right">-89.74%</div>
</div>
</div>
</div>
</div>
</div>
Had a night to think about it and realized i can add a max-width percentage, as well as a min-width percentage, to keep stacked progress bars at least wide enough to show a label on both.
.progress-bar {
min-width: 15%;
max-width: 85%;
}
http://jsfiddle.net/nimh/kx7hvxyz/8/
It's not perfect (may look funny with a 99% and 1%), but will work for showing a label at all times for our needs.
How about playing with the line-height and font-size?
[1]: http://www.bootply.com/Tq7YbaeOX5
/* CSS used here will be applied after bootstrap.css */
.max-width {
max-width: 25em;
}
/* .progress-bar {
min-width: 4em;
} */
.progress-bar {
padding: 4px;
line-height: 12px;
}
.text-Left {
font-size: 12px;
float: left;
}
.text-left, .text-right {
font-size: 7px;
padding-right:5px;
}
.text_Right {
float: right;
}
<div class="container-fluid">
<div class="row-fluid">
<div class="panel panel-default max-width">
<div class="panel-body">
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: 89.74%">
<div class="text-Left">+89.74%</div>
</div>
<div class="progress-bar progress-bar-danger" style="width: 10.26%">
<div class="text-right">-10.26%</div>
</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-success" style="width: 10.26%">
<div class="text-left">+10.26%</div>
</div>
<div class="progress-bar progress-bar-danger" style="width: 89.74%">
<div class="text_Right">-89.74%</div>
</div>
</div>
</div>
</div>
</div>
</div>
I have an in img in boostrap and i want it to show in right and to show 4 objects in the left in two rows each one has two objects which is 4 columns from the grid
My HTML
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12 img-container">
<div class="product first wow zoomInDown "
data-wow-delay="0.3s" data-wow-duration="2s">
<img src="images/hiro1.jpg" width="600" alt="" class="img-responsive" >
<h6 class="text-center">it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout</h6>
<p>Energy</p>
</div> <!-- end of product-->
</div> <!-- end of bootstrap columns-->
<div class="col-md-4 col-sm-6 col-xs-12 img-container">
<div class="product second wow zoomInDown "
data-wow-delay="0.3s" data-wow-duration="2s">
<img src="images/hiro2.jpg" width="600" alt="" class="img-responsive">
<h6 class="text-center">it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout</h6>
<p>Phyto</p>
</div> <!-- end of product-->
</div> <!-- end of bootstrap columns-->
<div class="banner">
<img src="http://placehold.it/300x450">
</div>
<div class="clearfix"></div>
<div class="col-md-4 col-sm-6 col-xs-12 img-container">
<div class="product second wow zoomInDown "
data-wow-delay="0.3s" data-wow-duration="2s">
<img src="images/hiro2.jpg" width="600" alt="" class="img-responsive">
<h6 class="text-center">it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout</h6>
<p>Phyto</p>
</div> <!-- end of product-->
</div> <!-- end of bootstrap columns-->
<div class="col-md-4 col-sm-6 col-xs-12 img-container">
<div class="product second wow zoomInDown "
data-wow-delay="0.3s" data-wow-duration="2s">
<img src="images/hiro2.jpg" width="600" alt="" class="img-responsive">
<h6 class="text-center">it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout</h6>
<p>Phyto</p>
</div> <!-- end of product-->
</div> <!-- end of bootstrap columns-->
</div> <!-- end of row-->
MY CSS
.product{ overflow: hidden; margin-bottom: 40px; position: relative; cursor: pointer; float: left;}
.product p {position: absolute; top: 10%; left:200%; color: white;
z-index: 2000; font-size: 20px; opacity:0; transition:all 0.5s;}
.product h6 {position: absolute; top: 40%; left:-200%; color: white;
z-index: 3000; font-size: 20px; opacity:0; transition:all 0.5s ; line-height: 20px;
transition-timing-function: cubic-bezier(0.000, 0.000, 0.580, 1.000); }
and this is the result that shows up
http://i.imgur.com/2PhECdx.jpg
I have modified your code to make two columns and the first column is containing two rows with two columns.
<div class="row">
<div class="col-md-8 col-sm-6 col-xs-12">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12 img-container">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 img-container">
</div>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12 img-container">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 img-container">
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 img-container">
</div>
</div>
Check this:
http://jsfiddle.net/h68hzfnc/