Actually the image is 450*450pixels (both height and width is 15.88cm)
so i want to adjust them in equally to screen please see my screen shot and as you see the name also came in the bottom of each image the name should not so much big and small too it just fit with the image
img {
padding float: left;
border-radius: 150%;
}
<h1>ACTOR</h1>
<img src="img/chadwick.jpg" alt="chadwick" height="15%" width="15%">
<img src="img/michael.jpg" alt="michel" height="15%" width="15%">
<img src="img/lupita.jpg" alt="lupita" height="15%" width="15%">
Bootstrap 3 solution
HTML structure
<div class="row">
<div class="col-...">
<img ...>
<h5>...</h5>
</div>
</div>
Added padding-left and padding-right to each column to make space. Added margin-top to <h5> (Could be something else).
Example
.my-row>div {
padding: 0 7vw;
}
.my-row h5 {
margin-top: 15px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row my-row">
<div class="col-xs-4 text-center">
<img src="http://placehold.it/450x450" alt="" class="img-responsive img-circle">
<h5>Name 1</h5>
</div>
<div class="col-xs-4 text-center">
<img src="http://placehold.it/450x450" alt="" class="img-responsive img-circle">
<h5>Name 2</h5>
</div>
<div class="col-xs-4 text-center">
<img src="http://placehold.it/450x450" alt="" class="img-responsive img-circle">
<h5>Name 3</h5>
</div>
</div>
Bootstrap 4 solution
<div class="row text-center">
<div class="col">
<div><img src="https://via.placeholder.com/450x450" alt="chadwick"></div>
<div>chadwick</div>
</div>
<div class="col">
<div><img src="https://via.placeholder.com/450x450" alt="michel"></div>
<div>michel</div>
</div>
<div class="col">
<div><img src="https://via.placeholder.com/450x450" alt="lupita"></div>
<div>lupita</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>
When adding the bootstrap class "img-fluid" to my images they don't appear, when inspecting the element it sets the image at 0x0 pixels.
The html:
<div class="col">
<div class="row no-gutters">
<div class="col">
<img src="assets/images/placeholder.png" class="img-fluid"
alt="placeholder">
</div>
<div class="col">
<img src="assets/images/placeholder.png" class="img-fluid" alt="placeholder">
</div>
<div class="w-100"></div>
<div class="col">
<img src="assets/images/placeholder.png" class="img-fluid" alt="placeholder">
</div>
<div class="col">
<img src="assets/images/placeholder.png" class="img-fluid" alt="placeholder">
</div>
</div>
</div>
The images are supposed to be the same size as the parent(div.col) and be responsive to the parent.
Here's an answer based on my comment.
Because you have a .col element as a child of a flex parent, the flex-basis is set to 0. That basically equates to width: 0.
To get around that, set the flex-basis to auto on the .col that are children of the .row element.
.row>.col {
flex-basis: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col">
<div class="row no-gutters">
<div class="col">
<img src="https://placehold.it/100x100" class="img-fluid" alt="placeholder">
</div>
<div class="col">
<img src="https://placehold.it/100x100" class="img-fluid" alt="placeholder">
</div>
<div class="w-100"></div>
<div class="col">
<img src="https://placehold.it/100x100" class="img-fluid" alt="placeholder">
</div>
<div class="col">
<img src="https://placehold.it/100x100" class="img-fluid" alt="placeholder">
</div>
</div>
</div>
So I have basically used manual percentages to make these images lie next together. As you see they are not very neatly layout or organized. How can I make it look more dashing?
Here's the code:
<div class="jumbotron jumbotron-fluid" style=" margin-top: 90px; ">
<div class="container">
<div class="row">
<div class="col-lg-2">
<img src="./assets/img/glass.jpg" class="img-responsive " style="width:95%"/>
<img src="./assets/img/rift.jpg" class="img-responsive m-y-1" style="width:95%;"/>
</div>
<div class="col-lg-8">
<img src="./assets/img/mhacks.jpg" class="img-responsive" style="width:100%; "/>
</div>
<div class="col-lg-2">
<img src="./assets/img/mindwave.png" class="img-responsive" style="width:120%;"/>
<img src="./assets/img/VR.png" class="img-responsive m-y-1" style="width:120%;"/>
</div>
</div>
</div>
</div>
Here's how it looks like:
http://imgur.com/e2I3yLu
Also here's the link to the website:
monajalal.github.io
Any suggestion is really appreciated. I wonder if there's a more straightforward method to image layout or any automatic method?
Set each image as a background image in a div:
<div class="jumbotron jumbotron-fluid" style=" margin-top: 90px; ">
<div class="container">
<div class="row">
<div class="col-lg-2">
<div style="background: url('./assets/img/glass.jpg'); background-size: cover;" class="img-responsive"></div>
<div style="background: url('./assets/img/rift.jpg'); background-size: cover;" class="img-responsive"></div>
</div>
<div class="col-lg-8">
<div style="background: url('./assets/img/mhacks.jpg'); background-size: cover;" class="img-responsive-large"></div>
</div>
<div class="col-lg-2">
<div style="background: url('./assets/img/mindwave.png'); background-size: cover;" class="img-responsive"></div>
<div style="background: url('./assets/img/VR.png'); background-size: cover;" class="img-responsive"></div>
</div>
</div>
</div>
</div>
Then set this css:
.img-responsive {padding-top: 60%; margin-bottom: 10px;}
.img-responsive-large {height: 208px; margin-bottom: 10px;}
#media screen and (max-width: 940px) {
.img-responsive-large {height: auto; padding-top: 60%;}
}
Try this... What I did was work with the grid. Use the padding from columns and even it with margins between the images, also set the images to 100% width. Class img-responsive sets a max-width of 100%, at least this way the image will fill the column.
<div class="jumbotron jumbotron-fluid">
<div class="container">
<div class="row">
<div class="col-lg-8">
<img src="http://www.online-image-editor.com//styles/2014/images/example_image.png" class="img-responsive"/>
</div>
<div class="col-lg-2">
<img src="http://www.online-image-editor.com//styles/2014/images/example_image.png" class="img-responsive "/>
<img src="http://www.online-image-editor.com//styles/2014/images/example_image.png" class="img-responsive m-y-1"/>
</div>
<div class="col-lg-2">
<img src="http://www.online-image-editor.com//styles/2014/images/example_image.png" class="img-responsive"/>
<img src="http://www.online-image-editor.com//styles/2014/images/example_image.png" class="img-responsive m-y-1"/>
</div>
</div>
</div>
</div>
Remove the inline styling - and instead target the images in the css and add this.
.jumbotron img { width: 100%; margin: 15px 0; }
The tomato picture is taller than the others even though I set height and width. I'm sure it's something simple:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-md-4">
<img src="http://i1121.photobucket.com/albums/l514/sterzarino/lightning.jpg" class="img-responsive projects img-thumbnail" width="230" height="230">
<div class="caption text-center">Weather App</div>
</div>
<div class="col-md-4">
<img src="http://i1121.photobucket.com/albums/l514/sterzarino/TomatoClock.jpg" class="img-responsive projects img-thumbnail" width="230" height="230">
<div class="caption text-center">Weather App</div>
</div>
<div class="col-md-4">
<img src="http://i1121.photobucket.com/albums/l514/sterzarino/soup.jpg" class="img-responsive projects img-thumbnail" width="230" height="230">
<div class="caption text-center">Recipe Book</div>
</div>
</div>
</div>
because you are using .img-responsive and .img-thumbnail which both set max-width:100% in CSS, therefore overriding the html width/height tags
Plus don't use HTML tags for width/height
To have it with same height you can do something like this (without losing aspect ratio):
.row img {
max-height: 120px
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-4 col-md-4 text-center">
<a href="#">
<img src="http://i1121.photobucket.com/albums/l514/sterzarino/lightning.jpg" class="img-responsive projects img-thumbnail">
</a>
<div class="caption">Weather App</div>
</div>
<div class="col-xs-4 col-md-4 text-center">
<a href="#">
<img src="http://i1121.photobucket.com/albums/l514/sterzarino/TomatoClock.jpg" class="img-responsive projects img-thumbnail">
</a>
<div class="caption">Weather App</div>
</div>
<div class="col-xs-4 col-md-4 text-center">
<a href="#">
<img src="http://i1121.photobucket.com/albums/l514/sterzarino/soup.jpg" class="img-responsive projects img-thumbnail">
</a>
<div class="caption">Recipe Book</div>
</div>
</div>
Set custom width and height like this in css to override bootstrap:
.img-thumbnail{
width: 230px;
height:230px;
}
I think it is bootstrap's responsive images messing with it. Override it in css like so
img {
width: 230px !important;
height: 230px !important;
}
Fiddle
I would suggest changing from using <img> to using the images as backgrounds. Bootstrap is not everything, you can still add your own styles if none seems fit.
Backgrounds are good because you can trim off the ends and it won't stretch the images.
.projects.img-thumbnail[style] {
width:100%;
height:200px;
background-size:cover;
background-position: center;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-4">
<span style="background-image: url(http://i1121.photobucket.com/albums/l514/sterzarino/lightning.jpg)" class="img-responsive projects img-thumbnail"></span>
<div class="caption text-center">Weather App</div>
</div>
<div class="col-xs-4">
<span style="background-image: url(http://i1121.photobucket.com/albums/l514/sterzarino/TomatoClock.jpg)" class="img-responsive projects img-thumbnail"></span>
<div class="caption text-center">Weather App</div>
</div>
<div class="col-xs-4">
<span style="background-image: url(http://i1121.photobucket.com/albums/l514/sterzarino/soup.jpg)" class="img-responsive projects img-thumbnail"></span>
<div class="caption text-center">Recipe Book</div>
</div>
</div>
But as far as I know, there is no easy way of making it a square except involving ::before or ::after pseudo selectors.
In my school project. I am trying to create a photo gallery like view but I need that between two photos some space comes the code is here
<div class="container">
<h2 style="text-align: center;">Physics</h2>
<br>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-2" style="background-color: aliceblue;">
<img class="img-responsive" class="thumbnail" class="img-center center-block" src="assets/GirishJain2.JPG" alt="Girish Jain">
<p style="text-align:justify;">
<b> Girish Jain</b> <br>
b.Tech,IIT-Delhi<br></br>
Exp 14 years
</p>
</div>
<div class="col-sm-6"></div>
<div class="col-md-2" style="background-color: lavender;">
<img class="img-responsive" src="assets/prateek.JPG" alt="Prateek Jain">
<p style="text-align:justify;">
<b> Prateek Jain</b> <br>
b.Tech-MNIT,Jaipu<br></br>
Exp 7 years
</p>
</div>
<div class="col-md-2" style="background-color: aliceblue;">
<img class="img-responsive" class="thumbnail" class="img-center center-block" src="assets/sidharthjain.JPG" alt="Siddharth Jain">
<p style="text-align:justify;">
<b> Sidharth Jain</b> <br>
b.Tech-MNIT,Jaipur<br></br>
Exp 14 years
</p>
</div>
</div>
</div>
and the pages like
below the physics section I want a some space between each photo
Allow the col-md-4 to continue to serve it's current purpose. You want the image to be inside of a div who's job will be to give space.
HTML
<div class="col-md-4 col-xs-4 col-sm-4">
<div class="image-padding">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
</div>
CSS
.image-padding {
padding: 5px;
}
.image-padding img {
width: 100%;
}
CodePen
http://codepen.io/Goosecode/pen/oxaEjR
use the below it will work fine with you wrap it inside your container div
<link href="https://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-6 col-xs-6 col-sm-6">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame&w=970"/>
</div>
<div class="col-md-6 col-xs-6 col-sm-6">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame&w=970"/>
</div>
</div>
<hr>
<!--for other images !-->
<div class="row">
<div class="col-md-4 col-xs-4 col-sm-4">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
<div class="col-md-4 col-xs-4 col-sm-4">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
<div class="col-md-4 col-xs-4 col-sm-4">
<img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Iame"/>
</div>
</div>
This can be easily achieved using Bootstrap.
HTML
<div class="col-md-4" id="element">
Your Content.
</div>
CSS
#element {
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
}