I'm displaying 3 pictures on my code. The pictures have different size (width and height).
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Gallery</h2>
</div>
<div class="col-md-4 col-sm-6">
<a >
<img class="img-responsive img-portfolio img-hover" src="../../imgVideos/test/1/pictureGallery1.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a >
<img class="img-responsive img-portfolio img-hover" src="../../imgVideos/test/1/pictureGallery2.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a >
<img class="img-responsive img-portfolio img-hover" src="../../imgVideos/test/1/pictureGallery3.jpg" alt="">
</a>
</div>
</div>
It loads and displays the pictures, but the sizes of the images are different. How can I set the height and width to have a default value?
Thanks
Use the height and width attributes on the image tag:
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Gallery</h2>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img height="100" width="100" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img height="100" width="100" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img height="100" width="100" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
</div>
Or use some CSS by setting the width and height rules and linking it to the images you want to affect:
#myImage {
width: 100px;
height: 100px;
}
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Gallery</h2>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img id="myImage" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img id="myImage" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img id="myImage" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
</div>
Another thing : in the above code, if the images you're using are not squares you might want to use width: auto or height: auto. Look below:
/* sets the width to 100px and the height will be calculate automatically to respect the dimensions */
#myImage1 {
width: 100px;
height: auto;
}
/* sets the height to 100px and the width will be calculate automatically to respect the dimensions */
#myImage2 {
width: auto;
height: 100px;
}
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Gallery</h2>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img id="myImage1" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
<div class="col-md-4 col-sm-6">
<a>
<img id="myImage2" class="img-responsive img-portfolio img-hover" src="https://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg" alt="">
</a>
</div>
</div>
You can use the CSS max-width property. This will limit the width of the images. If you set the limit less than or equal to the true width of the smallest image, they will all scale down to match that value. Note that you might need to also deal with vertical scaling in some browsers, but it is handled automatically in others.
Use height and width properties as:
<img class="img-responsive img-portfolio img-hover"
src="../../imgVideos/test/1/pictureGallery3.jpg" width="200px" height="200px"
alt="">
Related
I want to design like this in bootstrap css , picture
What i have tried is
<div class="row">
<div class="col-md-3">
<img class="img-responsive" src="img1.jpg">
</div>
<div class="col-md-6">
<img class="img-responsive" src="img3.jpg">
</div>
<div class="col-md-3">
<img class="img-responsive" src="img5.jpg">
</div>
<div class="col-md-3">
<img class="img-responsive" src="img2.jpg">
</div>
<div class="col-md-6">
<img class="img-responsive" src="img4.jpg">
</div>
<div class="col-md-3">
<img class="img-responsive" src="img6.jpg">
</div>
</div>
The height of images img1.jpg,img4.jpg,img5.jpg need to increase as shown in image attcahed,
Is there any Experts in CSS?
Add the .img-fluid class to each of your images so they scale with the parent div's. That should work.
https://getbootstrap.com/docs/4.0/content/images/#responsive-images
You can achieve the desired layout with modification on your html code. Try this code.
<div class="row">
<div class="col-md-3">
<img class="img-responsive" src="img1.jpg">
<br>
<img class="img-responsive" src="img2.jpg">
</div>
<div class="col-md-6">
<img class="img-responsive" src="img3.jpg">
<br>
<img class="img-responsive" src="img4.jpg">
</div>
<div class="col-md-3">
<img class="img-responsive" src="img5.jpg">
<br>
<img class="img-responsive" src="img6.jpg">
</div>
</div>
I wanted to create an image grid with one full image on the left and 4 thumbnail images on right of the big image. Something like what I've done here:
https://codepen.io/ashwindkini/pen/qabRok
<div class="container">
<div class="row">
<div class="col-md-6">
<img src="https://placehold.it/450x450" alt="" />
</div>
<div class="row">
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
</div>
How do I prevent the second set of images (thumbnails) from increasing the size of row?
Are you able to make the larger image actually a larger image so that it scales responsively in comparison with the smaller "thumbnails"?
It would help to remove padding from the columns so that the width of the image (forced by column padding) doesn't limit the height of the image.
Everything can go in a single row..
<div class="container">
<div class="row">
<div class="img col-sm-6 col-md-6">
<img src="//placehold.it/600/666" class="center-block img-responsive" alt="big image">
</div>
<div class="img col-xs-6 col-sm-6 col-md-3">
<img src="//placehold.it/450/EEE" class="img-responsive" >
</div>
<div class="img col-xs-6 col-sm-6 col-md-3">
<img src="//placehold.it/450" class="img-responsive" >
</div>
<div class="img col-xs-6 col-sm-6 col-md-3">
<img src="//placehold.it/450" class="img-responsive" >
</div>
<div class="img col-xs-6 col-sm-6 col-md-3">
<img src="//placehold.it/450/444" class="img-responsive" >
</div>
</div>
</div>
http://www.codeply.com/go/y9nZTlXSWT
The "row" element should not be a direct child of another row element. You should put it as a child of another col-md-6.
Here's the example:
https://codepen.io/anon/pen/dpGvOJ
<div class="container">
<div class="row">
<div class="col-md-6">
<img src="https://placehold.it/450x450" alt="" />
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
<div class="col-md-3">
<img src="https://placehold.it/450x450" alt="" class="img-responsive" />
</div>
</div>
</div>
</div>
</div>
I created a Bootstrap Thumbnail image grid originally and the HR would instantly jump below all of the images.
I decided to delete the Bootstrap image grid and change it to a Lightbox image grid which is so much better.
I've not got a problem that the HR which should be acting as a Footer HR, is now ignoring all of the pictures and is jumping straight back up to the top of the page.
Is this something to do with the pre-set CSS configuration within Lightbox?
HTML:
<div class="container lightbox">
<div class="gallery">
<div class="row row1">
<div class="col-md-3">
<a href="Pictures/Pic1.jpg" data-title="Picture #1" data-lightbox="Picture Number 1">
<img src="Pictures/Pic1.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic6.jpg" data-title="Picture #2" data-lightbox="Picture Number 2">
<img src="Pictures/Pic6.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic7.jpg" data-title="Picture #3" data-lightbox="Picture Number 3">
<img src="Pictures/Pic7.jpg" width="200px" class="img-thumbnail">
</a>
</div>
</div>
<div class="row row2">
<div class="col-md-3">
<a href="Pictures/Pic4.jpg" data-title="Picture #4" data-lightbox="Picture Number 4">
<img src="Pictures/Pic4.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic5.jpg" data-title="Picture #5" data-lightbox="Picture Number 5">
<img src="Pictures/Pic5.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic2.jpg" data-title="Picture #6" data-lightbox="Picture Number 6">
<img src="Pictures/Pic2.jpg" width="200px" class="img-thumbnail">
</a>
</div>
</div>
<div class="row row3">
<div class="col-md-3">
<a href="Pictures/Pic3.jpg" data-title="Picture #7" data-lightbox="Picture Number 7">
<img src="Pictures/Pic3.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic8.jpg" data-title="Picture #8" data-lightbox="Picture Number 8">
<img src="Pictures/Pic8.jpg" width="200px" class="img-thumbnail">
</a>
</div>
<div class="col-md-3">
<a href="Pictures/Pic9.jpg" data-title="Picture #9" data-lightbox="Picture Number 9">
<img src="Pictures/Pic9.jpg" width="200px" class="img-thumbnail">
</a>
</div>
</div>
</div>
</div>
<hr class="bigHR2">
Very basic custom CSS :
.bigHR1 {
background-color: white !important;
color: white !important;
border: 2px solid white !important;
border-radius: 50%;
height: 1px !important;
width: 850px !important;
margin-left: 5%;
margin-top: -1%;
}
.row1 {
margin-top: 50%;
}
.row2 {
margin-top: 10%;
}
.row3 {
margin-top: 10%;
}
Both Bootstrap and Lightbox are installed LOCALLY, and am having no problem with Bootstrap on other pages of this website, so it must be the Lightbox.
I am having a problem with bootstrap 3 and some thumbnails where although I'm using the same code and the image sizes are exactly the same the last image row is broken on mobile when in vertical only
Here is the code:
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=4">
<img class="img-responsive" src="http://mysite/tn-1_256x300.jpg" alt="">
<div class="text-center text_margin">styling</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=5">
<img class="img-responsive" src="http://mysite/tn-2_256x300.jpg" alt="">
<div class="text-center text_margin">colour</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=6">
<img class="img-responsive" src="http://mysite/tn-3_256x300.jpg" alt="">
<div class="text-center text_margin">extensions</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=7">
<img class="img-responsive" src="http://mysite/tn-4_256x300.jpg" alt="">
<div class="text-center text_margin">hair enhancements</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=8">
<img class="img-responsive" src="http://mysite/tn-5_256x300.jpg" alt="">
<div class="text-center text_margin">smoothing treatment</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="?service=9">
<img class="img-responsive" src="http://mysite/tn-6_256x300.jpg" alt="">
<div class="text-center text_margin">hair up</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="meet-the-team">
<img class="img-responsive" src="http://mysite/tn-7_256x300.jpg" alt="">
<div class="text-center text_margin">meet the team</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="/price-list/">
<img class="img-responsive" src="http://mysite/tn-8_256x300.jpg" alt="">
<div class="text-center text_margin">price list</div>
</a>
</div>
</div><!--end row-->
</div><!--end container-->
This is happening because some of the text below the thumbnails is wrapping, and as a result the thumbnail heights are different. One way to fix this problem is to clear the columns float on mobile with CSS like this..
#media (max-width: 768px) {
.row > .col-xs-6:nth-child(2n+1) {
clear: left;
}
}
Demo 1: http://codeply.com/go/Bgt8JFkPht
Another option (simpler), is to use CSS text-overflow ellipsis on the text DIV's since it's these DIVs that are causing the height to be different on each thumbnail. When the thumbnail heights are the same, the row wrapping is not an issue..
Demo 2: http://codeply.com/go/5uOP4bM5pk
Check your text-margin class, when adding a margin or padding to some items in Bootstrap, you change the width of your columns.
I'm trying to make this grid work but I'm not sure what's the best approach here. I have this page with several thumbnails and each thumbnail has a title. The problem is that when the title length is very long it pushes the thumbnail and everything get messy like this:
I would like to find a way to keep thumbnails aligned, so if there is a very long title instead of pushing that thumbnail down, it pushes the whole row.
This is the markup I have so far for this block of thumbnails:
<div class="container">
<div class="content row">
<div class="col-lg-12">
<h1>Fresh Goals and More</h1>
<hr>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title That is Very Long So I Can Test How does Long Titles Behave in My web site display<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<h2>Test Title<h2>
<a class="thumbnail" href="#">
<div class="vignette">
<img class="img-responsive" src="img/placeholder.jpg">
</div>
</a>
</div>
</div><!-- content row close -->
</div><!-- container close -->
Any hint on how can I fix this? Thanks in advance.
this is simple you have to have a row for four thumbs
<div class="row">
<div class="col-md-3">thumb</div><div class="col-md-3">thumb</div><div class="col-md-3">thumb</div>
</div>
<div class="row">
<div class="col-md-3">thumb</div><div class="col-md-3">thumb</div><div class="col-md-3">thumb</div>
</div>
the row will keep the height of the longest column with children thumb
http://www.bootply.com/6C7i5iRZhz