Bootstrap images not displayed in a single row - html

I've been trying to create few images that should be displayed in a single row.
Currently it is displayed one-by-one.
Here's my code:
# CSS:
.emblems-section {
z-index: 1;
text-align: center;
}
<header>
<div class="container">
<div class="row">
<div class="col-md-12 emblems-section justify-content-center align-items-center">
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/leagueEmblem.png" class="img-fluid" alt="Statistics for League of Legends">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/overwatchEmblem.png" class="img-fluid" alt="Statistics for Overwatch">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/dotaEmblem.png" class="img-fluid" alt="Statistics for Dota2">
</div>
</div>
</div>
</div>
</header>

For anyone looking for the same solution, the answer is d-flex within the parent div.

<div class="container">
<div class="row">
<div class="col-md-12 emblems-section justify-content-center align-items-center">
<div class="row">
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/leagueEmblem.png" class="img-fluid" alt="Statistics for League of Legends">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/overwatchEmblem.png" class="img-fluid" alt="Statistics for Overwatch">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/dotaEmblem.png" class="img-fluid" alt="Statistics for Dota2">
</div>
</div>
</div>
</div>
</div>
//you have to add row after col-md-12

It is best practice that try to avoid unnecessary div or other elements in code structure. so you don't need to use col-md-12 just replace col-md-12 to row class and remove duplicate row div.
Use below code, by using this you can remove one unrequired div element, so your code looks compressed and beautiful.
<header>
<div class="container">
<div class="row emblems-section justify-content-center align-items-center">
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/leagueEmblem.png" class="img-fluid" alt="Statistics for League of Legends">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/overwatchEmblem.png" class="img-fluid" alt="Statistics for Overwatch">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/dotaEmblem.png" class="img-fluid" alt="Statistics for Dota2">
</div>
</div>
</div>
</header>

<div class="container">
<div class="row">
<div class="col-md-12 d-flex emblems-section justify-content-center align-items-center">
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/leagueEmblem.png" class="img-fluid" alt="Statistics for League of Legends">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/overwatchEmblem.png" class="img-fluid" alt="Statistics for Overwatch">
</div>
<div class="col-lg-4 col-md-4 col-xs-4">
<img src="img/dotaEmblem.png" class="img-fluid" alt="Statistics for Dota2">
</div>
</div>
</div>
</div>
you can add d-flex class with col-md-12

Related

Why wont my code that is using Bootstrap add horizontal space between the rows of thumbnails?

I am making a thumbnail grid using bootstrap. The vertical spacing in between the images automatically appears, however the there is not horizontal spacing. the images are touching one another.
I have tried rearranging divs.
it should automatically have even space around every thumb nail
<!---jumbo-->
<div class ="container">
<div class="jumbotron">
<h1 class="display-4"><i class="fas fa-camera"></i> Image Gallery</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
</div>
<!--Images-->
<div class="row">
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg"class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg" class="img-thumbnail">
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg"class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg" class="img-thumbnail">
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg"class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="web images/darkbutterfly.jpg" class="img-thumbnail">
</div>
</div>
</div>
If I understood you correctly then this should be the answer, check it out - https://codepen.io/anon/pen/MRgdgX
<div class ="container">
<div class="jumbotron row">
<div class="col-12">
<h1 class="display-4"><i class="fas fa-camera"></i> Image Gallery</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
</div>
<div class="row">
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
<div class="col-lg-4 col-md-6">
<img src="https://via.placeholder.com/300" class="img-thumbnail">
</div>
</div>
.row {
display: flex;
flex-wrap: wrap;
}
.jumbotron {
margin: 0 1rem;
}
img {
display: flex;
margin: 1rem;
}

Put space between row for bootstrap image gallery

I am using bootstrap and i want to create space between row 1 and row 2. There are 6 images together and row 1 and 2 has 3 images in each row
This is my code for each image
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
<img src="images/1thumb.png" alt="Main">
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
<img src="images/2thumb.jpg" alt="Elevator1">
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
<img src="images/3thumb.jpg" alt="Elevator2">
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
<img src="images/4thumb.jpg" alt="Elevator3">
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
<img src="images/5thumb.jpg" alt="Interior">
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-6 ">
<img src="images/6thumb.jpg" alt="Reception">
</div>
</div>
</div>
You can just add margin bottom to the columns.
Something like
.row > div { margin-bottom: 15px}

Is there a better way to load images onto a website other than the img tag?

I was wondering if there was a better way to load images to a HTML file other than the <img> tag. I ask this because I am building a website that has a photo gallery. This photo gallery has 48 pictures and it seems to take forever to load.
Here is my HTML code for this page:
<!--IMAGES-->
<div class="container">
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/Africabound_1.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0226.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0232.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0299.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0330.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0364.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0374.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0392.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0425.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0480.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0543.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0548.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0566.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSC_0615.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0841.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0902.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0909.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0914.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0929.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0957.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN0970.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1024.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1034.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1065.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1095.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1099.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1128.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1130.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1134.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1179.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1221.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1283.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1312.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1313.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1342.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1404.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1417.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1528.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1541.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1623.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/DSCN1624.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/IMG_1836.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/IMG_1849.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/Photo May 14, 01 17 06.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/Photo May 14, 01 22 01.JPG">
</div>
</div>
</div>
<div class="row">
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/Photo May 14, 02 05 57.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/Photo May 14, 02 28 54.JPG">
</div>
</div>
<div class=" col-xs-4 col-md-4 ">
<div class="thumbnail">
<img src="AfricaPictures/Photo May 14, 03 54 52.JPG">
</div>
</div>
</div>
</div>
</body>
</html>
<head>
As you can see, this is a monstrous three-hundred and sixteen lines of code. There must be a better way and I hope you will share it with me. Thanks in advance.
The <img>-element is the one to go for.
Be aware (if not already) that photos on the web should'nt exceed something like 500kb in file size (as a rule of thumb at least). Meaning you need reduce photo-size and kick out pixels. Here is a sample website where you can do it:
http://jpeg-optimizer.com/
As per the definition of HTML, <img> tags are one way to load image. You can also use background images, figures and the sort but the end result will be the same and there must always be a container to contain the image.
There is a lot of code going on there but sadly, the end result is a bit unavoidable. If you use rendering tools, it gives you the illusion that you are not managing it but in the end, the printed result will likely be the same once the code is rendered.
For your solution, there's a away to save a few lines left and right:
You can only wrap all your bootstrap columns in one row, since they are using float rules, you will save up a bit.
Hope this helps!

Website content

I've tried many ways to code but none of them works. The 3 products are listed vertically in one column. But I have no idea on how to separate the the following <div> containing 6 others product into different columns beside it. Can you help me to solve this?
Or, in other ways, can the <div> is actually aligned into 3 products per row, not in column?
<div class="products-right-grids-position1">
<h4>BUN BOY Bakery</h4>
<p>Best Bakery in Town </p>
<p> </p>
</div>
</div>
</div>
<div class="products-right-grids-bottom">
<div class="col-md-4 products-right-grids-bottom-grid">
<?php
echo getPros();
?>
<?php
echo getBreadPros();
?>
</div>
<div class="clearfix"> </div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid">
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
About
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<img src="https://www.google.ca/images/srpr/logo11w.png" style="width: 100px">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
SHARE
</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
About
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<img src="https://www.google.ca/images/srpr/logo11w.png" style="width: 100px">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
SHARE
</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
About
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<img src="https://www.google.ca/images/srpr/logo11w.png" style="width: 100px">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
SHARE
</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
About
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<img src="https://www.google.ca/images/srpr/logo11w.png" style="width: 100px">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
SHARE
</div>
</div>
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
About
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<img src="https://www.google.ca/images/srpr/logo11w.png" style="width: 100px">
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
SHARE
</div>
</div>
</div>

How to do work with odd number of columns in bootstrap

Usually we can't make <div> center align while working with odd columns. Here is my problem.
This is developed using Bootstrap. I want all inner divs to be in the center. So, when the page is viewed on other devices everything is center-aligned. When viewed at md screen width there is a little space on right side.
I want three columns at md and lg widths, two columns at sm widths, and one column at xs width. On all viewports, it should be center-aligned.
Here is my markup:
<div class="container-fluid">
<div class="row-fluid">
<div class="fleet_bor col-lg-4 col-md-4 col-sm-4 col-xs-12 col-centered">
<a href="http://someurl.com/gulfstream-iii/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/III-01-300x240.jpg" />
</a>
<h4>Gulfstream III</h4>
</div>
<div class="fleet_bor col-lg-4 col-md-4 col-sm-4 col-xs-12">
<a href="http://someurl.com/gulfstream-iv-sp-1/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/V2-1-300x240.jpg" />
</a>
<h4>Gulfstream V2</h4>
</div>
<div class="fleet_bor col-lg-4 col-md-4 col-sm-4 col-xs-12">
<a href="http://someurl.com/gulfstream-iv-sp-1/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/FLEET_SP1.jpg" />
</a>
<h4>Gulfstream SP1</h4>
</div>
<div>
</div>
I have found a best solution regarding this, i have this issue due to odd number of columns so i just added a span column on left and right side and the working columns in middle, that it solved my problem!, here is code what i did.
<div class="entry-content">
<div class="col-lg-1 col-md-1 col-sm-1 hidden-xs"></div>
<div class="col-lg-10 col-md-10 col-sm-11 col-xs-12 moile_fix_">
<div class="fleet_bor col-lg-4 col-md-4 col-sm-6 col-xs-12">
<a href="http://someurl.com/gulfstream-iii/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/III-01-300x240.jpg">
</a>
<h4>Gulfstream III</h4>
</div>
<div class="fleet_bor col-lg-4 col-lg-offset-0 col-md-4 col-md-offset-2 col-sm-4 col-sm-offset-0 col-xs-12 col-xs-offset-0">
<a href="http://someurl.com/gulfstream-iv-sp-1/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/V2-1-300x240.jpg">
</a>
<h4>Gulfstream V2</h4>
</div>
<div class="fleet_bor col-lg-4 col-md-4 col-sm-6 col-xs-12">
<a href="http://someurl.com/gulfstream-iv-sp-1/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/FLEET_SP1.jpg">
</a>
<h4>Gulfstream SP1</h4>
</div>
<div class="fleet_bor col-lg-4 col-lg-offset-0 col-md-4 col-md-offset-2 col-sm-4 col-sm-offset-0 col-xs-12 col-xs-offset-0">
<a href="http://someurl.com/gulfstream-g550/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/G5500-1-300x244.jpg">
</a>
<h4>Gulfstream G550</h4>
</div>
<div class="fleet_bor col-lg-4 col-md-4 col-sm-6 col-xs-12">
<a href="http://someurl.com/gulfstream-v1/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/V1-1-300x240.jpg">
</a>
<h4>Gulfstream V1</h4>
</div>
<div class="fleet_bor col-lg-4 col-lg-offset-0 col-md-4 col-md-offset-2 col-sm-4 col-sm-offset-0 col-xs-12 col-xs-offset-0">
<a href="http://someurl.com/gulfstream-iv-sp-2/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/FLEET_SP2.jpg">
</a>
<h4>Gulfstream SP2</h4>
</div>
<div class="fleet_bor col-lg-4 col-md-4 col-sm-6 col-xs-12">
<a href="http://someurl.com/gulfstream-iv-sp-3/">
<img class="img-responsive" src="http://someurl.com/wp-content/uploads/2014/11/FLEET-SP3.jpg">
</a>
<h4>Gulfstream SP3</h4>
</div>
</div>
<div class="col-lg-1 col-md-1 hidden-sm hidden-xs"></div>
</div>
Wrap in outer div and offset the col.
It is not perfect, but it works. You'll need to make the transition fluid as well, but it should help you get everything centered-ish
http://getbootstrap.com/css/#grid-offsetting