align images on same line/row/div in larger screen - html

There are a set of 3 images which align below each other (display:block) for screens less than 768 px. Now for screens of a larger size, the images should be displayed inline-block with text below them(centered), and they should resize themselves responsively on the same horizontal level, as the browser window resizes.
Now, here's what I have tried with the following results:
Trial 1:
HTML:
<div class="row container-fluid rowimg" id="row4">
<div class="conatiner-fluid col-sm-12 images">
<div class="conatiner-fluid col-sm-4 smcar">
<figure class="carimg">
<img src="images/Small Car.jpg" class="media-object pull-left" alt="Small Car">
<figcaption>Car 1</figcaption>
</figure>
</div>
<div class="conatiner-fluid col-sm-4 fmlcar">
<figure class="carimg">
<img src="images/Family Car.jpg" class="media-object pull-left" alt="Family Car">
<figcaption>Car 2</figcaption>
</figure>
</div>
<div class="conatiner-fluid col-sm-4 medcar">
<figure class=" carimg">
<img src="images/Medium Car.jpg" class="media-object pull-left" alt="Medium Car">
<figcaption>Car 3</figcaption>
</figure>
</div>
</div>
CSS:
#media (min-width: 768px) {
#row4{
border: 1px dotted red;
margin:0;
padding:0;
text-align:center;
}
figure {
display: inline-block;
border: 1px dotted gray;
padding:0;
margin:0;
vertical-align: bottom;
}
figure img {
vertical-align: bottom;
display:inline-block;
}
figure figcaption {
border: 1px dotted green;
text-align: center;
display:inline-block;
vertical-align: bottom;
}
}
The result is div's overlapping each other:
Trial 2:
Upon adding 'img-responsive' in the image's class, the images resize well, but the middle image floats up, even with vertical-align: bottom. It doesn't' matter whether I include ""media-object pull-left " or not. I am getting the following result:
Now I have tried various versions of these since the last 24 hours(that's why the separate classes for each image div), read numerous SO posts, added float, cleared floats, used relative and absolute positioning, with bottom:0 (that put my images on same line, but images were not behaving in a responsive manner). Also, I don't get why there are the extra spaces between the container and the content-div's. I did explicitly set margin and padding to 0. The middle image has gone up, and it has gone down, but it refuses to line up. The images have overflown the div, and they have shrunk too much. I have even tried resizing the images to have the same height, (but why should I do that in a responsive design?).
For the life of me, please help me figure this out.

just use structure like this:
<div class="row">
<div class="col-xs-12 col-sm-4">
img, text...
</div>
<div class="col-xs-12 col-sm-4">
img, text...
</div>
<div class="col-xs-12 col-sm-4">
img, text...
</div>
</div>
col-xs-12 used for display element with 100% width on screens <768px. col-sm-4 for 33% width on screens >768px.
Read this for better understanding: Bootstrap grid system
Set the same height property for image containers, overflow: hidden, text-align: center; and set 100% height on img element. So you will get images of the same height and cropped on sides.

Related

Bootstrap responsive image will not stay in center

I'm trying to line up three pictures within a bootstrap grid. All of the images were centered, which is what I'm trying to, before I added a img-responsive class to one of the images. I do however want the images to be responsive while also making them a tiny bit larger than they are already. Tried numerous things such as "width: 200%;" however without success
How it looks
I created a "center-all" class within my css that should center all the three of them, and it did work, just until I added the img-responsive class to the red one. The class was not added to any of the other images.
.center-all {
text-align: center;
align-items: center;
align-content: center
vertical-align: center;
}
JSFiddle
https://jsfiddle.net/8a6ee7f5/
Images doesn't work in Fiddle ofc.
What I want to achieve:
I want the images to be 2 times larger than what they currently are and I want them to be responsive while still keeping them centered.
Thanks in advance!
I found the answer to my question(s).
When adding the img-responsive class to the image it moves to the left. By adding "center-block" to the class to the image it should stay in the center.
<img src="..." class="img-responsive center-block">
Now I just need to find the answer on how to upscale my pictures to 200%.
EDIT:
I found the following to upscale my images:
CSS
.wrapper {
width: 40%;
}
and added that to my image class.
HTML
<img src="..." class="img-responsive center-block wrapper">
And that fixed it.
So bootstrap already has an element centering class called .text-center you can just add this class to the row wrapping your items and everything in that row will be centered. Then instead of using .img-responsive you can add a width to the image instead or give the image a percentage width. It will maybe look something like the following hopefully this is what you are looking for:
Here is a fiddle Updated Fiddle
note: I have added a border-radius of 50% to your images because I assume you want them to be round. If you want to use 100px you can change it back.
Css:
#values img{
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
width: 80%;
}
#val1 {
background-color: #792c24;
}
#val2 {
background-color: #4f5e6d;
}
#val3 {
background-color: #665e25;
}
Html:
<div class="container" id="values">
<h3 class="fancy">Values</h3>
<div class="row text-center">
<div class="col-sm-4">
<h4>Independent</h4>
<img id="val1" src="http://placehold.it/300x300">
</div>
<div class="col-sm-4">
<h4>Team Player</h4>
<img id="val2" src="http://placehold.it/300x300">
</div>
<div class="col-sm-4">
<h4>Dedicate</h4>
<img id="val3" src="http://placehold.it/300x300">
</div>
</div>
</div>

How to handle an image inside bootstrap column?

I got bootstrap col-md-1 that contains an image inside. Moreover, that column is wrapped by content div with paddings.
The problem I'm not okay with is that this image is pretty small. I would like it to be with the size at least as the original one has,
yet it should be responsive.
How can I do this? Thanks in advance!
My Codepen
HTML
<div class="content">
<div class="row">
<div class="col-md-11 first-column"></div>
<div class="col-md-1 back-to-blog">
<a href="/">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
</a>
</div>
</div>
</div>
</div>
CSS
.content {
padding: 0 35px;
}
.first-column {
border: 1px solid;
height: 100px;
}
One of the 'blanket' styles that BootStrap ships with is this:
img {
max-width: 100%;
}
This essentially means that images won't go wider than their parent containers / elements. So if your col-md-1 has a width of 97.5px (assuming you're using a normal 1170px container?), your image won't be bigger than 97.5px on viewports > 992px.
Try experimenting with different sized columns:
<div class="col-md-10 first-column"></div>
<div class="col-md-2 back-to-blog">
<a href="/">
<img class="img-responsive" src="https://api.asm.skype.com/v1/objects/0-neu-d1-6d077751650ba9cb23f065b16e4d4581/views/imgpsh_fullsize">
</a>
</div>
Or, for larger viewports, try appending another class to your wrapping container and overrides BootStrap's native container class:
<div class="container container-custom">
Then style is as follows:
#media (min-width: 1420px) {
.container.container-custom {
width: 1390px
}
}
Doing this will ensure your column widths remain proportionate to your container size (they are percentage based after all) and most importantly, you're not overwriting BootStrap!
You'll also notice I've wrapped the above class in a media query. This is so viewports > 1420px have the 1390px container with spacing either side (due to container's margin-left: auto and margin-right: auto which center it in the viewport).

Image overlapping parent div responsiveness

What I'm trying to achieve is the image outside of the parent div's boundaries, which works in 1280x1024. How can I make this effect responsive?
Html:
<div class='row'>
<div class="divider">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 wow fadeInRight" data-wow-delay="1s" data-wow-duration="1.5s">
<img src="http://karsbarendrecht.nl/5/wp-content/uploads/2015/10/responsive.png" alt="laptop tablet phone responsive"/>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 wow fadeInRight" data-wow-delay="1s" data-wow-duration="1.5s">
<h1>bla bla bla.</h1>
</div>
</div>
</div>
CSS:
.divider{
margin-top:100px;
min-height:175px;
margin-bottom:100px;
background-size: cover!important;
background-attachment: scroll;
background-image: url('http://karsbarendrecht.nl/5/wp-content/uploads/2015/10/triangles.svg');
}
.divider div{
top:-50px;
The following image show's my problem, with the top half being the desired effect. And the bottom half is what happens when resizing the screen to smaller resolutions.
The problem seems to be that the image is resizing itself but the parent div is not, in this case I would change the values in pixels to values in vh and vw (these are percentages of "viewport height" and "veiwport width": the height and width of the window you are resizing.) for example:
margin-top:100px;
would become
margin-top:8vh;
By placing both the background image and the front image in HTML, and adding the following css rules they both scale the same.
.divider div{
top:-50px; // placing the image slightly above the divider div
height:125%; // making the div containing the image bigger than the divider div
}
.divider img{
width:100%; // just for this image because it isnt wide enough
position:absolute; // make sure the image listens to top:-50px;
}
ps: the images scale because of twitter bootstrap's css:
img {
height: auto;
max-width: 100%;
}

Placing images in a twitter bootstrap's grid

Need to place images kinda like here (for example): http://imgur.com/QpRjvpW
Original pictures of different sizes.
Hover effect - blur and fogging effects and text on the middle of the picture.
Here is what I got for now: JSFiddle
So the question, how correctly position them, so that they occupy the entire width of the screen by 3 in a row, gonna be same size, closely adhering to the upper and lower div and to each other, don't expand within its borders? And the effect of the blur doesn't touch neighboring elements?
Remove class row and col-lg-12,use col-sm-12 like
<div class="col-sm-12">
<div id="work1" class="col-sm-4">
<img class="image" src="http://i.telegraph.co.uk/multimedia/archive/03257/POTD-SKY-SQUIRREL_3257854k.jpg">
<p class="text">ONE</p>
</div>
<div id="work2" class="col-sm-4">
<img class="image" src="http://i.telegraph.co.uk/multimedia/archive/03235/potd-husky_3235255k.jpg">
<p class="text">TWO</p>
</div>
<div id="work3" class="col-sm-4">
<img class="image" src="http://s.hswstatic.com/gif/dolphin-pictures-1.jpg">
<p class="text">THREE</p>
</div>
</div>
CSS:
works img {
height: 600px;
width: 100%;}
Apply this css, you'll get the look like the example --
.works img{
display:block;
max-width:100%;
}
.works [class^="col-"] {
padding-left:0;
padding-right:0;
}
.works .text{
position:absolute !important;
left: 0;
right: 0;
}

Images vertically aligned using display:inline-block not aligning

The images display one atop another, not in a horizontal line, no idea why.
Just need them to align horizontally.....
HTML
<div id="detail_image_wrapper">
<div class="detail_images">
<img id="left_detail" src="images/LeftDetailImg.png" alt="Phone image">
</div>
<div class="detail_images">
<img id="centre_detail" src="images/CentreDetailImg.png" alt="Phone image">
</div>
<div class="detail_images">
<img id="right_detail" src="images/RightDetailImg.png" alt="Phone image">
</div>
</div>
CSS
div.detail_images {
width: 203px;
vertical-align: top;
display: inline-block;
}
You need to add a width property to the images, not just the image container. Otherwise the images will not resize to fit into their container and they will overflow it, causing them to overlap. Example: JSFiddle
Add this to your CSS:
.detail_images img {
width: 203px;
}
You can adjust the width of the images as needed.