Bootstrap 13th column is displaying vertically - html

I made a row with 100 columns and each should be as small as possible. But as you can see below the 13th column is acting odd.
all the images and columns are generated using the same code so each height should be the same. I do know the 12 column rule for bootstrap, but I'm okay with it wrapping around at 12 or 40 I dont have a width rule in the application. Also if anyone can help the images are responsive but the column count is not if i shrink the window it goes straight to one column per row instead of say 11 and then 10 and so forth and so on.
<div class="form-horizontal container" id="ActualHallOfLights">
<div class="row">
<div class="thumbnail col-sm-1"> 1:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 2:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 3:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 4:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 5:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 6:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 7:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 8:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 9:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 10:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 11:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 12:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 13:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
<div class="thumbnail col-sm-1"> 14:False
<Img alt="False" class="img-responsive" height="50" src="/Images/LightBulbOff.jpg" width="35" />
</div>
<div class="thumbnail col-sm-1"> 15:True
<Img alt="True" class="img-responsive" height="50" src="/Images/LightBulbOn.jpg" width="40" />
</div>
</div>
</div>

Your images probably vary slightly in height, possibly due to sub-pixel rounding. For this reason, the column elements that contain them also vary. This disrupts float behavior.
One common solution is to set a minimum height on the columns (or the images). Another is to set your images as backgrounds instead, with a size of cover, and use the responsive element to set heights. You could just be sure your images all have exactly the same original size, but that's a fragile approach. Even one faulty image breaks the layout.
In any event, they all need to be the same height.

removed the image tag and added these styles to the div containing the image
.bgLightOn {
background-image: url('/Images/LightBulbOn.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: bottom;
width: 70px;
height: 110px;
}

As i see in the image, LightBulbOff and LightBulbOn image have slightly difference in height. The height of both images must have same size. Or you may use clearfix class after each 12th image.

Related

Different height and position for col in bootstrap [duplicate]

This question already has answers here:
CSS-only masonry layout
(4 answers)
Closed 3 years ago.
I wrote this code for insert image in order to create a grid full of photos:
<section class="gallery-section">
<div class="container grid-custom" style="padding-top: 50px;">
<div class="row">
<div style="padding: 0px;" class="text-center col-md-4 gallery-image">
<img src="./images/cover.jpg" alt="" class="img-fluid">
</div>
<div style="padding: 0px;" class="my-auto text-center col-md-4 gallery-image">
<img src="./images/passero.jpg" alt="" class="img-fluid">
</div>
<div style="padding: 0px;" class="text-center col-md-4 gallery-image">
<img src="./images/cigno.JPG" alt="" class="img-fluid">
</div>
</div>
<div class="row">
<div style="padding: 0px;" class="text-center col-md-4 gallery-image">
<img src="./images/pic1.jpg" alt="" class="img-fluid">
</div>
<div style="padding: 0px;" class="text-center col-md-4 gallery-image">
<img src="./images/fiore.JPG" alt="" class="img-fluid">
</div>
<div style="padding: 0px;" class="text-center col-md-4 gallery-image">
<img src="./images/sfondo7.jpg" alt="" class="img-fluid">
</div>
</div>
</div>
</section>
But I get this result:
What should I do instead to get a result like this?
You are placing 3 images per div.row, which results in this layout:
As you can see, the div.row elements are stacked, and each div.row is as high as its highest image, creating gaps for the remaining space in each row.
In summary, you have divided the grid first by rows, and then by columns.
What you need is a masonry grid. As opposite to your approach, this grid is divided first by columns, and then by rows or images.
The main concept behind a masonry grid resides in an approach like this:
<!-- Left column -->
<div class="col-md-4">
<img src="" alt="Top image">
<img src="" alt="Middle image">
<img src="" alt="Bottom image">
</div>
<!-- Center column -->
<div class="col-md-4">
<img src="" alt="Top image">
<img src="" alt="Middle image">
<img src="" alt="Bottom image">
</div>
<!-- Right column -->
<div class="col-md-4">
<img src="" alt="Top image">
<img src="" alt="Middle image">
<img src="" alt="Bottom image">
</div>
What you are looking for is a Masonry Layout.
There are a lot of websites that give nice tutorials. Here for instance I would refer to https://css-tricks.com/piecing-together-approaches-for-a-css-masonry-layout/

HTML default image size

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="">

displaying 3 images in a row with text underneath in bootstrap

I am trying to display 3 images in a row with a title, some text underneath the title and a button. I have tried doing this in bootstrap only to get the text moving all over the place. This seems like the only way I could get the text to stay put, but now as you can see my images are stacked on top of each other rather than next to each other. Any help would be appreciated!
<section class="part2">
<div class="container">
<div class="row">
<div class="text-center">
<img alt="" class="resize-image" id="image1" src="/wp-content/themes/creativeforces/images/kid2.jpg">
<p>Teach</p>
<img alt="" class="resize-image" id="image2" src="/wp-content/themes/creativeforces/images/kid2.jpg">
<p>Read</p>
<img alt="" class="resize-image" id="image3" src="/wp-content/themes/creativeforces/images/kid2.jpg">
<p>Play</p>
</div>
</div>
</div>
this is what it looks like now
i am trying to get it to look something like this
You will need to add grids to your rows. This should work
<section class="part2">
<div class="container">
<div class="row">
<div class="col-md-4">
<img alt="" class="resize-image center-block" id="image1" src="/wp-content/themes/creativeforces/images/kid2.jpg" />
<p class="text-center">Teach</p></div>
<div class="col-md-4"><img alt="" class="resize-image center-block" id="image2" src="/wp-content/themes/creativeforces/images/kid2.jpg" />
<p class="text-center">Read</p></div>
<div class="col-md-4"><img alt="" class="resize-image center-block" id="image3" src="/wp-content/themes/creativeforces/images/kid2.jpg" />
<p class="text-center">Play</p></div>
</div>
</div>
</section>
Please use this example. You need to use bootstrap grid classes like "col-md-x" where x is number from 1 to 12.
<section class="part2">
<div class="container">
<div class="row">
<div class="col-md-4 text-center">
<img alt="" class="resize-image" id="image2" src="/wp-content/themes/creativeforces/images/kid2.jpg">
<p>Read</p>
</div>
<div class="col-md-4 text-center">
<img alt="" class="resize-image" id="image1" src="/wp-content/themes/creativeforces/images/kid2.jpg">
<p>Teach</p>
</div>
<div class="col-md-4 text-center">
<img alt="" class="resize-image" id="image3" src="/wp-content/themes/creativeforces/images/kid2.jpg">
<p>Play</p>
</div>
</div>

Creating a responsive row

I'm trying to create a responsive row that, when displayed on an iPad, the 3 images go across the screen like on desktop. Currently they are behaving like they are on mobile and expanding vertically, not horizontally.
The images are the 3 product range images on the website: http://dekatest.neto.com.au/
<div class="container" style="text-align:center;">
<div class="row"><img alt="" src="/assets/images/MEDICAL-RANGE.jpg" style="max-width:100%;" /><img alt="" src="/assets/images/SPROTS-RANGE.jpg" style="max-width:100%;" /><img alt="" src="/assets/images/WELLBEING-RANGE.jpg" style="max-width:100%;" /></div>
</div>
If you are using Bootstrap try something like this
<div class="container text-center">
<div class="row">
<div class="col-sm-4">
<img alt="" src="/assets/images/MEDICAL-RANGE.jpg" />
</div>
<div class="col-sm-4">
<img alt="" src="/assets/images/SPROTS-RANGE.jpg" />
</div>
<div class="col-sm-4">
<img alt="" src="/assets/images/WELLBEING-RANGE.jpg" />
</div>
</div>
</div
and with CSS add the properties and styles to your tags
img { max-width: 100%; }
Note: you should change the value of col-sm-* depending on what you are trying to do.
if you are only using row just because of that you don't need padding between images. So simple is that make separate class for controlling padding of col-sm. You should have to use col-* inside row then it will be work fine.
CSS
.no-p{
padding-left:0px;
paddding-right:0px;
}
HTML
<div class="container text-center">
<div class="row">
<div class="col-xs-4 no-p">
<img class="img-responsive" alt="" src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" />
</div>
<div class="col-xs-4 no-p">
<img class="img-responsive" alt="" src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" />
</div>
<div class="col-xs-4 no-p">
<img class="img-responsive" alt="" src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" />
</div>
</div>
</div>
View on JsFiddle: https://jsfiddle.net/L2y3ybff/

Twitter Bootstrap with tiles centered

I am creating an app using bootstrap which house tile like style. I am new to this web designing and I bit struggling to get these tiles arranged. My requirement is, I would like to place 4 tiles inside a carousel such that each slide should contain 4 tiles.
I tried using col-cm-6 to divide the container equally. But tile stays to left aligned.
<div class="container">
<div class="row">
<h1>Sample tiles using bootstrap classes</h1>
<div class="row">
<div class="col-sm-6">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive danger" /></a>
</div>
<div class="col-sm-6 ">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive" /></a>
</div>
<div class="col-sm-6 ">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive" /></a>
</div>
<div class="col-sm-6 ">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive" /></a>
</div>
</div>
</div>
</div>
Could anyone please tell me what I am missing.
Regards,
Raaj
Usetext-center
DEMO: demo full screen
<div class="container text-center">
<h1>Sample tiles using bootstrap classes</h1>
<div class="row">
<div class="col-sm-6">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive danger" /></a>
</div>
<div class="col-sm-6 ">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive" /></a>
</div>
<div class="col-sm-6 ">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive" /></a>
</div>
<div class="col-sm-6 ">
<a href="#" title="Image 1">
<img src="//placehold.it/250x250" class="thumbnail img-responsive" /></a>
</div>
</div>
</div>
CSS:
.thumbnail {
margin: 0 auto;
}