Bootstrap thumbnails too small on mobile - html

I have a set of Bootstrap thumbnails on my web page and I have set all the images with class .img-responsive. When I open the page on a mobile browser the thumbnails are appearing too small and I can't even resize them with css.
Here are my thumbnails:
<div class="row">
<div class="col-xs-6 col-md-3">
<a href="#" class="thumbnail">
<img src="images/thumbnails/traditional.jpg" class="img-rounded img-responsive" alt="...">
</a>
</div>
<div class="col-xs-6 col-md-3">
<a href="#" class="thumbnail">
<img src="images/thumbnails/mehndi.jpg" class="img-rounded img-responsive" alt="...">
</a>
</div>
... altogether 12 thumbnails
</div>
I have tried to edit the size of the thumbnails for mobile phone size devices with the following media query:
#media(max-width:767px){
.thumbnail > img {
height:70px;
width:120px;
}
}
However the width doesn't seem to surpass 80px, it seems like I can only set width up to around 80px and anything higher won't do anything.
If I leave the thumbnails like they are without trying the above CSS code they appear too small on mobile devices and I need a way to increase the size of the thumbnails on mobile devices only.
Here is a link to the site:

Change col-xs-6 to col-xs-12
So instead of
<div class="col-xs-6 col-md-3">
You'll have
<div class="col-xs-12 col-md-3">
This will make it so that each thumbnail will take up the full width of the phone, instead of having two across.

I have fixed the problem, I found that I had the below code elsewhere in my CSS that I didn't take notice of. This below media query was what made my images appear so small on mobile devices, I took it out and now images appear fine. Thanks for the help guys.
#media(max-width:767px){
.thumbnail > img {
height:40px;
}
}

Related

How do I add margin above images in Bootstrap3?

When I make the browser window small, the images are clumped together, I want to add some spacing between them, when they stack vertically, note that I also want to do this in pure bootstrap, because I know how to do it in css.
Code:
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<img class="img-responsive center-block" src="http://via.placeholder.com/250x250">
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<img class="img-responsive center-block" src="http://via.placeholder.com/250x250">
</div>
#media (max-width: 767px) {
img {
margin-bottom: 15px;
display: block;
overflow: hidden;
}
}
You can use it with media query to control every element in different screens.
Thia code control the extra small screen like mobile screen.. it will add margin bottom to every image.
Follow the link to know more about media query
https://www.w3schools.com/css/css_rwd_mediaqueries.asp

Setting Images Side by Side & responsive in bootstrap

I have written a code where 4 images are kept inside div side by side in cols.
Below is the code :
<div class="container-fluid">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="image2.jpg" alt="1" style="width:100%; height:70%;" class="img-responsive" />
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="image3.jpg" alt="1" style="width:100%; height:70%;" class="img-responsive"/>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="image4.jpg" alt="1" style="width:100%; height:70%;" class="img-responsive"/>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<img src="image5.jpg" alt="1" style="width:100%; height:70%;" class="img-responsive"/>
</div>
</div>
</div>
This looks like this in full size window :
enter image description here
Now when the window size is minimized, the images looks like this :
enter image description here
I want the image to look the way it looks in the full size even after minimizing without the image getting stretched.
I was able to get the view of above images without it getting stretched when i removed the style: width:100%; height:70%; but then in full sized window the images had blank spaces between each other.
Please help me to get this sorted.
Using
class="img-responsive"
will make your images responsive across devices. In specific, and as per Bootstrap's documentation, it will add
max-width: 100%;
height: auto;
display: block;
to your image elements.
You will need to lose your inline styles
style="width:100%; height:70%;"
as they override everything else (Protip: never use them).
Lastly, if you don't want the blank spaces between images you'll need to force remove the padding for each column. Example:
div.col-xs-3 {
padding: 0;
}
Here is a sample codepen.
#FredRocha hey Fred, I tried using only img-reponsive & losing the inline styles but then the images were looking like this in full screen window size:
Example image
Maybe adding img-responsive class to image will fix the problem.

Editing bootstrap CSS to hide an image

I've got an image that is displayed when viewing the website on a computer; however, I want it to be hidden when the site is viewed on a mobile device. I've just used the 'display: none;' CSS but for some reason it's not working.
HTML:
<div class="col-sm-7 col-sm-offset-1">
<img src="./images/testing.jpg" alt="">
</div>
CSS:
.col-sm-7 {
display:none;
}
Thank you.
Just add the class hidden-xs and/or hidden-sm.
See the docs for more info
Try using Bootstrap Responsive Utilities
.hidden-xs
<div class="col-sm-7 col-sm-offset-1 hidden-xs">
<img src="./images/testing.jpg" alt="">
</div>

HTML/CSS not working responsively when device is less than 400px wide

If someone could take a quick look at this code and give advice, that would be much appreciated.
I have some images that resize correctly on both iPad and PC screens. However, as soon as you try it on a phone/reduce browser window size, the image does not resize correctly.
CSS:
.col-md-2 {
width: 16.66666667%;
}
HTML:
<div class="col-md-2 col-sm-4">
<div class="timeline-thumb">
<div class="thumb">
<img src="images/timeline6.jpg" alt="">
</div>
<div class="overlay">
<div class="timeline-caption">
<h4>Wrapping Services</h4>
<p>Click for more info</p>
</div>
</div>
</div>
</div>
The image is 170px wide, and there are 6 of them in a line, that all highlight in grey (via CSS) when you roll the mouse over them.
When i resize my browser to that of a phone, they get bigger than before!
Any advice much appreciated.
If someone is knowledgeable on the subject and can help please contact me and ill try to provide any info you need.
Thanks.
I'm trying to understand if you are using Bootstrap. If so, you should add a class for the small devices, try to add a col-xs-4 or col-xs-6 to the DIV element that is "col-md-2 col-sm-4" now.
Looks like Bootstrap. If so, add the img-responsive helper class to your image.
<img class="img-responsive" src="images/timeline6.jpg" alt="">
This will allow your image to scale proportionately and fill 100% width of the containing div regardless of viewport size.

Retaining Aspect Ratio on DIVs with Fixed Gutter and Parent Padding

Haven't asked something here in a long time. I'm trying to build my design portfolio, and since I'm not really a front-end developer I lack a lot of knowledge, but that's why I'm here :)
I've got a container which is a DIV with a given padding. Inside I'll have a grid consisting of fluid-width cards. What would be the best option, or how to proceed towards that, for retaining the card aspect ratio (square) and the gutter between cards when resizing the parent element?
Simply put, I'm looking for something like the attached image:
So no matter the screen size, the gutter and padding will stay the same while the cards change their width to fill up the space.
I'm looking for something as CSS-pure as possible. Where should I look?
Thank you!
I am not sure if i got it right. Nenad's solution seems to be good. But i understood that the cards always stay 3 in a row doesn't matter how big or small the screen is (if this makes sense on every screen is another question now). I made you a fiddle in which you don't have to use pictures, you just have to include a little bit of JQuery Code, it's not much.
var divWidth = $('.square').width();
$('.square').height(divWidth);
Please see my fiddle here: https://jsfiddle.net/ee128fy2/
It would be no problem editing this for smaller screens to not have 3 squares in a row.
Note that the square height will not change when you resize your browser window, it will change on pageload. But anyway, i think no one will resize the window when looking on it on mobile phone or something.
Edit:
If you use pictures instead of jquery, resize will work live when scaling the browser window.
You can do this using boostrap https://jsfiddle.net/2Lzo9vfc/60/
HTML
<div class="container-fluid">
<div class="row">
<div class="col-sm-4 portfolio-item">
<img src="http://placehold.it/350x350" class="img-responsive" alt="">
</div>
<div class="col-sm-4 portfolio-item">
<img src="http://placehold.it/350x350" class="img-responsive" alt="">
</div>
<div class="col-sm-4 portfolio-item">
<img src="http://placehold.it/350x350" class="img-responsive" alt="">
</div>
</div>
<div class="row">
<div class="col-sm-4 portfolio-item">
<img src="http://placehold.it/350x350" class="img-responsive" alt="">
</div>
<div class="col-sm-4 portfolio-item">
<img src="http://placehold.it/350x350" class="img-responsive" alt="">
</div>
<div class="col-sm-4 portfolio-item">
<img src="http://placehold.it/350x350" class="img-responsive" alt="">
</div>
</div>
</div>
CSS
.portfolio-item {
margin: 20px 0;
}
#media(max-width: 768px) {
.portfolio-item {
margin: 20px auto;
width: 100%;
text-align: center;
}
.portfolio-item img{
margin: 0 auto;
}
}