I want to get the grid system to center but it won't, i was thinking maybe it has something to do with my pictures' border?. here's the screen shotwhat it is right now
what i want it to be
HTML:
<div class=" container">
<div class="row">
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
</div>
</div>
CSS:
.optionBorder
{
border: 1px solid #f5f5f5;
height: 130px;
width: 130px;
line-height: 130px;
text-align: center;
}
Take another element before row with some width and make them center
for example.:
HTML
<div class="test">
<div class="row">
<div class="col-md-4">
<div class="optionBorder">
<img src="http://placehold.it/350x150" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="http://placehold.it/350x150" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="http://placehold.it/350x150" height="74px" width="50px">
</div>
</div>
</div>
</div>
CSS
.test {
width: 450px;
margin: auto;
margin-bottom: 15px;
}
bootply
<style>
.paraentCont{
width:100%;
max-width:300px;
margin:auto;
}
</style>
<div class=" container">
<div class="paraentCont">
<div class="row">
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
</div>
Give to .row fixed width such as 700px, and margin-left/right auto
look at this example http://www.bootply.com/GFDHc6p5tg
Actually here is there right way to go while using Bootsrap
Use the predefine class text-center
Use q Bootstrap helper like .inline-block{display: inline-block}
.inline-block{display: inline-block}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class=" container">
<div class="row text-center">
<div class="col-md-4 inline-block">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4 inline-block">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
<div class="col-md-4 inline-block">
<div class="optionBorder">
<img src="images/page-1.svg" height="74px" width="50px">
</div>
</div>
</div>
</div>
Related
I'm using Bootstrap and trying to make 3 images to be centered. For example, red color boxes are how my images look like, and I want to make it look like blue color boxes:
I tried getting rid of the margin and padding, but I still want some space between the images. Also I tried using { display: table; }, display: table-cell; vertical-align: middle; but somehow it does not do anything to my images... Is there a way to get images to the center with some padding to them in Bootstrap? Below is my code:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
.row {
display: flex;
align-items: center;
justify-content: center;
}
.column {
flex: 33.33%;
padding: 50px;
width: 100%;
}
<div class="album text-center">
<div class="row">
<div class="column">
<img src="images/tour1.jpeg" alt="one" style="width:100%">
</div>
<div class="column">
<img src="images/tour2.jpg" alt="two" style="width:100%">
</div>
<div class="column">
<img src="images/tour3.jpeg" alt="three" style="width:100%">
</div>
<div class="column">
<img src="images/tour1.jpeg" alt="one" style="width:100%">
</div>
<div class="column">
<img src="images/tour2.jpg" alt="two" style="width:100%">
</div>
<div class="column">
<img src="images/tour3.jpeg" alt="three" style="width:100%">
</div>
</div>
</div>
Thank you!
Bootstrap 4 has justify-content-around class which does the job. Consider to use narrower container If you want to obtain smaller gap between images.
PS: You should avoid using col class within image wrappers.
<div class="container">
<div class="row justify-content-around">
<div class="colx"><img src="https://place-hold.it/200x400" alt="" class="img-fluid"></div>
<div class="colx"><img src="https://place-hold.it/200x400" alt="" class="img-fluid"></div>
<div class="colx"><img src="https://place-hold.it/200x400" alt="" class="img-fluid"></div>
</div>
</div>
JSFiddle
Just add this class "justify-content-around".
<div class="album">
<div class="row justify-content-around">
<div class="column">
<img src="images/tour1.jpeg" alt="one" style="width:100%">
</div>
<div class="column">
<img src="images/tour2.jpg" alt="two" style="width:100%">
</div>
<div class="column">
<img src="images/tour3.jpeg" alt="three" style="width:100%">
</div>
<div class="column">
<img src="images/tour1.jpeg" alt="one" style="width:100%">
</div>
<div class="column">
<img src="images/tour2.jpg" alt="two" style="width:100%">
</div>
<div class="column">
<img src="images/tour3.jpeg" alt="three" style="width:100%">
</div>
</div>
</div>
I have a code like below - columns with full-width images.
<div class="col-3">
<img src="..." class="w-100" />
<div>Name</div>
</div>
As images can be of different size, it's not guaranteed that content below images will be displayed in one line (image's height is supposed to differ, depending on image's width).
In other words, when an image within .col is 200 px width, should be 200 px height, etc. (width = height).
Example 1 with css:
#import url('https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css');
.img-prev {
height: 200px;
overflow: hidden;
}
.img-prev img {
max-height: 100%;
width: auto;
max-width: inherit;
margin: auto;
display: block;
}
<div class="container">
<div class="row">
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538356913997-b04286765811?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=39e83600a508d87be2ea636e02f30f95&auto=format&fit=crop&w=600&q=60" alt="" class="img-fluid">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538333785596-1cc0b5e03551?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c942fc493dad02801a99aa191414a535&auto=format&fit=crop&w=600&q=60" alt="" class="img-fluid">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538379585867-44bf200a3d25?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=29782178fb2019f60bee12c2fcfacff4&auto=format&fit=crop&w=600&q=60" alt="" class="img-fluid">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538367735494-5e6cc0ff555a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=3066861f0cf81849de20853676dee717&auto=format&fit=crop&w=600&q=60" alt="" class="img-fluid">
</div>
</div>
</div>
</div>
Example 2 html:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538356913997-b04286765811?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=39e83600a508d87be2ea636e02f30f95&auto=format&fit=crop&w=600&q=60" alt="" height="200" width="150">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538333785596-1cc0b5e03551?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c942fc493dad02801a99aa191414a535&auto=format&fit=crop&w=600&q=60" alt="" height="200" width="150">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538379585867-44bf200a3d25?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=29782178fb2019f60bee12c2fcfacff4&auto=format&fit=crop&w=600&q=60" alt="" height="200" width="150">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538367735494-5e6cc0ff555a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=3066861f0cf81849de20853676dee717&auto=format&fit=crop&w=600&q=60" alt="" height="200" width="150">
</div>
</div>
</div>
</div>
Example 3 with jq:
var imgs = $('.img-prev>img');
imgs.each(function(){
var item = $(this).closest('.img-prev');
item.css({
'background-image': 'url(' + $(this).attr('src') + ')',
'background-position': 'center center',
'-webkit-background-size': 'cover',
'background-size': 'cover',
});
$(this).hide();
});
.img-prev {
height: 200px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<div class="container">
<div class="row img-list">
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538356913997-b04286765811?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=39e83600a508d87be2ea636e02f30f95&auto=format&fit=crop&w=600&q=60" alt="">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538333785596-1cc0b5e03551?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c942fc493dad02801a99aa191414a535&auto=format&fit=crop&w=600&q=60" alt="">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538379585867-44bf200a3d25?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=29782178fb2019f60bee12c2fcfacff4&auto=format&fit=crop&w=600&q=60" alt="">
</div>
</div>
<div class="col-4 mb-2">
<div class="img-prev">
<img src="https://images.unsplash.com/photo-1538367735494-5e6cc0ff555a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=3066861f0cf81849de20853676dee717&auto=format&fit=crop&w=600&q=60" alt="">
</div>
</div>
</div>
</div>
try this one,
<div class="container">
<img src="loginBackground.jpg" class="img-fluid" alt="Cinque Terre" width="200" height="200">
</div>
I need to made this div in bootstrap 3 as shows in image...
I need to display 4 icons/images in one row and another 4 icons in another row in smaller screen/mobile view..i dont know any error in my code..
please help me to make this as shown as in image.
<section class="container-fluid">
<div class="row" style="background-color:#034ea2;">
<div class="col-md-2"></div>
<div class="col-md-1 text-center ">
<div class="im1">
<img src="/images/speaker.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Sound insultion</h6>
</div>
</div>
<div class="col-md-1 text-center" >
<div class="im1">
<img src="/images/renewable-energy.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Save energy</h6>
</div>
</div>
<div class="col-md-1 text-center">
<div class="im1">
<img src="/images/window.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Prevent Dust Buildup</h6>
</div>
</div>
<div class="col-md-1 text-center">
<div class="im1">
<img src="/images/stormy.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Storm Resistant</h6>
</div>
</div>
<div class="col-md-1 text-center">
<div class="im1">
<img src="/images/hotel-elevator.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Elegant Looks</h6>
</div>
</div>
<div class="col-md-1 text-center">
<div class="im1">
<img src="/images/umb.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Blocks Seepage</h6>
</div>
</div>
<div class="col-md-1 text-center">
<div class="im1">
<img src="/images/sun.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Thermal Insulation</h6>
</div>
</div>
<div class="col-md-1 text-center">
<div class="im1">
<img src="/images/maintenance.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Low maintenance</h6>
</div>
</div>
<div class="col-md-2">
</div>
</div>
</section>
styles
.im1{
padding-top: 8px;
padding-left: 8px;
}
.siz{
width: 40px;
}
.textt{
font-size: 15px;
color:#ffffff;
font-family: 'Times New Roman', Times, serif !important;
}
Here is the image
how to make this image using bootstrap grid system...
I created a code for you. I hope it will help to you.
https://codepen.io/myco27/pen/OvMdGp
img{
width: 100%;
}
.img1{
width: calc(100% / 8);
float:left;
}
#media (max-width: 860px) {
.img1{
width: calc(100% / 4);
float:left;
}
}
<section class="container-fluid">
<div class="row" style="background-color:#034ea2;">
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
<div class="img1 text-center">
<img src="https://webfoundation.org/docs/2017/03/March-12-Letter.jpg" alt="1">
</div>
</div>
</section>
First bootstrap runs in a 12 grid sysytem that is defined or can be broken down into 2,3, or 4 segements...basically any divisor of 12. In your case, to get the first four images in a row (in a small device), we split the grid by 3 i.e "col-md-3" for each image wrapper and "col-lg-1" (for large devices) e.g using a snippet from your code
<div class="col-lg-1 col-md-3 text-center">
<div class="im1">
<img src="/images/hotel-elevator.png" alt="1" class="siz">
</div>
<div class="textt">
<h6>Elegant Looks</h6>
</div>
</div>
Then avoid splitting the grid at the main <div class="col-md-2"></div> wrapper, simply leave it as <div class="row justify-content-md-center"></div>.
This should work just fine.
NB: The number of images willbe only 8 in this container
For Your CSS is simply modify the following
.siz{
width: 100%;
}
Try This. it has 8 div in 1 row. as shown in image
<style>
.main{
background:#034da2;
}
</style>
<div class="col-md-12 main">
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
<div class="col-md-3">
<img src="image" alt="your image"/>
</div>
</div>
</div>
</div>
</div>
</div>
Hi guys I need help in organizing a group of images using the bootstrap grid layout.
In the image there is the result I want reach: https://i.stack.imgur.com/RuJud.png
My code produces this result: https://i.stack.imgur.com/ZDa2Z.png
The position of the images is wrong, can you help me watching my code?
<div class="container">
<div class="row game-group-titles">
<div class="col-md-6">
<h4>GIOCHI PREFERITI</h4>
<div class="row">
<div class="col-md-12 giocogrosso">
<img src="../lggioco.png" alt="">
</div>
</div>
<div class="row">
<div class="col-md-6 giocopiccoloo">
<img src="../giocoo.png" alt="">
</div>
<div class="col-md-6 giocopiccolo">
<img src="../giocoo.png" alt="">
</div>
</div>
<div class="row">
<div class="col-md-6 giocopiccoloo">
<img src="../giocoo.png" alt="">
</div>
<div class="col-md-6 giocopiccolo">
<img src="../giocoo.png" alt="">
</div>
</div>
</div>
<div class="col-md-6">
<h4>CURRENTLY PLAYING</h4>
<div class="row">
<div class="col-md-12 giocogrosso">
<img src="../lggioco.png" alt="">
</div>
</div>
<div class="row">
<div class="col-md-6 giocopiccoloo">
<img src="../giocoo.png" alt="">
</div>
<div class="col-md-6 giocopiccolo">
<img src="../giocoo.png" alt="">
</div>
</div>
<div class="row">
<div class="col-md-6 giocopiccoloo">
<img src="../giocoo.png" alt="">
</div>
<div class="col-md-6 giocopiccolo">
<img src="../giocoo.png" alt="">
</div>
</div>
</div>
</div>
</div>
Not sure if this is what you were looking for
.row {
background: blue;
max-width: 410px;
}
.no-gutters {
margin-right: 0;
margin-left: 0;
> .col, > [class*="col-"] {
padding-right: 0;
padding-left: 0;
}
}
<h4>GIOCHI PREFERITI</h4>
<div class="row no-gutters">
<div class="col-12 giocogrosso">
<img src="http://via.placeholder.com/410x190" alt="">
</div>
<div class="col-xs-6 giocopiccoloo">
<img src="http://via.placeholder.com/205x95" alt="">
</div>
<div class="col-xs-6 giocopiccoloo">
<img src="http://via.placeholder.com/205x95" alt="">
</div>
<div class="col-xs-6 giocopiccoloo">
<img src="http://via.placeholder.com/205x95" alt="">
</div>
<div class="col-xs-6 giocopiccolo">
<img src="http://via.placeholder.com/205x95" alt="">
</div>
</div>
I have divided my grid system following way.
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="slider"></div>
<!--divided column into 6/6-->
<div class="col-md-6">
<img src="img/2.jpg" style="width: 150px;height: 150px;" class="img-thumbnail" />
<img src="img/2.jpg" style="width: 150px;height: 150px;" class="img-thumbnail"/>
<img src="img/2.jpg" style="width: 150px;height: 150px;" class="img-thumbnail"/>
</div>
<div class="col-md-6">
<p>some content with image</p>
</div>
</div>
<div class="col-md-4">
some content plus image
</div>
</div>
</div>
My problem is I can't set 3 images in that div because of less width. Can any one tell how I can make it work. If I am doing any think wrong in my grid system please guide me.
Thank you
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="slider"></div>
<!--divided column into 6/6-->
<div class="col-md-6">
<div class="col-md-4">
<img src="img/2.jpg" style="width: 150px;height: 150px;" class="img-thumbnail" />
</div>
<div class="col-md-4">
<img src="img/2.jpg" style="width: 150px;height: 150px;" class="img-thumbnail"/>
</div>
<div class="col-md-4">
<img src="img/2.jpg" style="width: 150px;height: 150px;" class="img-thumbnail"/>
</div>
</div>
<div class="col-md-6">
<p>some content with image</p>
</div>
</div>
<div class="col-md-4">
some content plus image
</div>
</div>
Hope This will work..
You can use with to adding a custom class
.thumb_img .img-thumbnail{
width:32%;
padding:4px;
margin-right:1%;
float:left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-8">
<div class="slider"></div>
<!--divided column into 6/6-->
<div class="col-md-6 thumb_img">
<div class="row">
<img src="img/2.jpg" class="img-thumbnail img-responsive" />
<img src="img/2.jpg" class="img-thumbnail img-responsive" />
<img src="img/2.jpg" class="img-thumbnail img-responsive" />
</div>
</div>
<div class="col-md-6">
<p>some content with image</p>
</div>
</div>
</div>
</div>
Not a 100% sure about your question but..
1) you can only nest col-'s in row's. i.e:
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
2) each time you've divided a row in multiple columns, then inside the nested row you have 12 columns available again. i.e:
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-md-6">
</div>
<div class="col-md-6">
</div>
</div>
</div>
<div class="col-md-4">
</div>
</div>
Or you can create 3 columns inside a row:
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>
</div>
<div class="col-md-4">
</div>
</div>
I.e. 4 * 3 = 12 columns.