Make the image layout more organized using bootstrap and CSS - html

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; }

Related

How to make some image fit with the bootstrap columns with auto zoom image to fill the column

And this is my code :
<div class="row">
<div class="col-12">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-12">
<div class="xon-card">
<img class="img-fluid" src="https://www.adidas.co.id/media/scandiweb/slider/9/6/960x500_3_.jpg" alt="">
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12">
<img class="img-fluid" src="https://www.adidas.co.id/media/scandiweb/slider/m/e/mermaid--teaser-update-5.jpg" alt="">
</div>
</div>
</div>
</div>
After that I want to make some button like that
I'm using bootstrap 5.
add style to img:
width: 100%;
height: 100%;
object-fit: cover;
I guess you can handle it by flex-wrap. See the link below.
https://getbootstrap.com/docs/4.0/utilities/flex/#wrap

Bootstrap images in columns overlapping

I have been trying to get 3 images to be responsive using bootstrap columns. They seem to be responsive, but the problem is that the images overlap except for the last column which remains being normal.
<div class="row">
<div class="col-sm-2 offset-sm-3">
<img class="img-responsive" src="../assets/images/roy-creates-categories-02.png">
</div>
<div class="col-sm-2">
<img class="img-responsive" src="../assets/images/roy-creates-categories-02.png">
</div>
<div class="col-sm-2">
<img class="img-responsive" src="../assets/images/roy-creates-categories-02.png">
</div>
</div>
I would like all 3 columns to like the one all the way on the right.
I've tried adding class "img-responsive" & "img-fluid" and neither have worked.
I'm using bootstrap 4.0.
The images are overflowing their container. The image on the right is full height but it is overflowing its container. Using the bootstrap '.col-2' means that you are limiting the column widths based on the window width. You could use background css rules instead of img elements to ensure containment or coverage of images or you could just use .col-auto instead of .col-2 with .justify-content-center provided you have appropriately sized images.
All three examples are in the snippet.
.row {
min-height: 150px;
}
.col-auto {
background-color: green;
}
.col-sm-2 {
background-color: red;
}
.bg-image {
width: 100%;
height: 100%;
background-image: url("https://picsum.photos/100");
background-position: center;
background-size: contain;
background-repeat: no-repeat;
}
.bg-image.bg-image--cover {
background-size: cover;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="row justify-content-center">
<div class="col-auto">
<img class="img-fluid" src="https://picsum.photos/100">
</div>
<div class="col-auto">
<img class="img-fluid" src="https://picsum.photos/100">
</div>
<div class="col-auto">
<img class="img-fluid" src="https://picsum.photos/100">
</div>
</div>
<div class="row">
<div class="col-sm-2 offset-sm-3">
<div class="bg-image"></div>
</div>
<div class="col-sm-2">
<div class="bg-image"></div>
</div>
<div class="col-sm-2">
<div class="bg-image"></div>
</div>
</div>
<div class="row">
<div class="col-sm-2 offset-sm-3">
<div class="bg-image bg-image--cover"></div>
</div>
<div class="col-sm-2">
<div class="bg-image bg-image--cover"></div>
</div>
<div class="col-sm-2">
<div class="bg-image bg-image--cover"></div>
</div>
</div>

divide three images equally and image name too appear their recpective image

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>

Why isn't height behaving for an img in a bootstrap column?

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.

How to handle responsive image in bootstrap on smaller media?

Hi I am new in using bootstrap and I am not very good handling responsive image in bootstrap.
So here is my question.
I have images result formation like this on 992px:
but when I change my screen width to smaller media (e.g:520px) the images come in line with no gaps in it.
It become like this.
I want it like this with padding(gaps) in it.
here is my HTML code:
<!--two columes 3/1-->
<div id="first" class="row">
<div class="col-md-8"><img src="http://placehold.it/640x450" class="img-responsive"></div>
<div class="col-md-4"><img src="http://placehold.it/300x450" class="img-responsive"></div>
</div>
<div id="clean">
<!--two columes 3/1-->
<div id="second" class="row">
<div class="col-md-8">
<img src="http://placehold.it/640x100" class="img-responsive">
<br>
<br>
<img src="http://placehold.it/640x330" class="img-responsive"></div>
<div class="col-md-4"><img src="http://placehold.it/300x470" class="img-responsive"></div>
</div>
<!--two columes half half-->
<div class="row" id="third">
<div class="col-md-6"><img src="http://placehold.it/470x470" class="img-responsive"></div>
<div class="col-md-6"><img src="http://placehold.it/470x470" class="img-responsive"></div>
</div>
<!--four columes-->
<div class="row" id="forth">
<div class="col-xs-6 col-sm-3"><img src="http://placehold.it/250x250" class="img-responsive"></div>
<div class="col-xs-6 col-sm-3"><img src="http://placehold.it/250x250" class="img-responsive"></div>
<!-- Add the extra clearfix for only the required viewport -->
<div class="clearfix visible-xs"></div>
<div class="col-xs-6 col-sm-3"><img src="http://placehold.it/250x250" class="img-responsive"></div>
<div class="col-xs-6 col-sm-3"><img src="http://placehold.it/250x250" class="img-responsive"></div>
</div>
And here is CSS:
#first
{
padding:20px;
}
#second
{
padding:20px;
}
#third
{
padding:20px;
}
#forth
{
padding:20px;
}
And this is its fiddle
You can use two sets of images.
<div id="first" class="row">
<div class="col-md-8">
<img src="http://placehold.it/640x450" class="img-responsive hidden-xs hidden-sm">
<img src="http://placehold.it/700x450" class="img-responsive visible-xs visible-sm">
</div>
<div class="col-md-4">
<img src="http://placehold.it/300x450" class="img-responsive hidden-xs hidden-sm">
<img src="http://placehold.it/700x450" class="img-responsive visible-xs visible-sm">
</div>
</div>
And the css can go like:
.img-responsive {
width: 100%;
}
It will be a good option to use 2 sets in this case because re-sizing a 640x450 image to 700x450 will alter its aspect ratio.
You can read more about responsive utilities provided by bootstrap here:
http://getbootstrap.com/css/#responsive-utilities
Bootstrap don't wan't to increase your images sizes- that's the deal.
Easy way to solve the problem:
use this meta-tag <meta name="viewport" content="width=device-width, initial-scale=1">
and media queries, like this:
#media all and (max-width: 699px) and (min-width: 520px), (min-width: 1151px) {
img {
width: 700px;
height: auto;
}
}
It's just example. Change exactly width of query for your need.