Bootstrap - how to make the image being scaled down to fit the window height?
Tags: javascript,jquery,html,css,twitter-bootstrap-3
Problem :
How can I make the image overflow height responsive?
The images I have sometimes have long heights which make the window scroll bar visible.
So I want to make these heights responsive - to make the image being scaled down to fit the window height.
Is it possible?
CSS,
html, body {
height: 100%;
margin: 0;
padding: 0 0;
border: 4px solid black;
}
.container-fluid {
height: 100%;
display: table;
width: 100%;
padding-right: 0;
padding-left: 0;
border: 4px solid blue;
}
.row-fluid {
height: 100%;
display: table-cell;
vertical-align: middle;
width: 100%;
border: 4px solid red;
}
.centering {
float: none;
margin: 0 auto;
}
HTML,
<div class="container-fluid">
<div class="row-fluid text-center">
<div>
<img src="images/xxx.jpg" class="img-responsive centering">
</div>
</div>
</div>
Solution :
You can use height: 100%
and vertical-align: top
on img
and on parent element use height: 100vh
body, html {
margin: 0;
padding: 0;
}
div {
display: inline-block;
height: 100vh;
width: 100%;
text-align: center;
}
img {
height: 100%;
vertical-align: top;
}
<div>
<img src="http://placehold.it/400x850">
</div>
CSS Howto..
Check out this tutorial. I don't know how crossbrowser compatible it is (as it is CSS3), but it achieves the effect you want. HTML: <div> <h2></h2> </div> CSS: div {...
How are you displaying the image? You can't perform CSS operations on an ImageResource directly, but neither can you display it directly. You have to stick it in an Image,...
The only way this is possible with pure CSS is by using the Multiple Column Module. http://cssdeck.com/labs/qi1g3b4e .foo { columns: 2; } Prefixes may be required: http://caniuse.com/#feat=multicolumn...
It's not possible to do this in CSS if the font doesn't contain a solid cloud image. It is possible to do this with an SVG image. Fortunately, the font...
Here's the basic idea of an HTML form, which will post the values of your selected radio buttons. You can review the POST by looking at a dev tool like...
Demo Hi now your markup is wrong please change to your markup html and css write as like this HTML <div> <p> <label>Name: </label> <span>John</span> <label>Age: </label><span>35</span></p> <p><label>Level: </label><span>60</span>...
The only absolute way to make sure your rule will take precedence over the others is to use the !important keyword: .c1.c2 { color: red !important; } Note that if...
I found a solution that worked for me: I had two similar elements in my html page that I needed to hide working only from the CSS. <div class="notToBeHidden"> <label...
I want the last one to have a different size as i wish to change the width and padding of it. So if you meant last child of level 1...
Add this lines to your css : #nav ul li.right:hover { border-radius: 14px; border-bottom-left-radius:0; border-top-left-radius:0; width:137px; } #nav ul li.left:hover { border-radius: 14px; border-bottom-right-radius:0; border-top-right-radius:0; } and change the li...
Try deleting the height property of the header and give it a padding-bottom of about say 15px for the shadow. That should do the trick.
MyDiv001.style.cssText will return only inline styles, that was set by style attribute or property. You could use getComputedStyle to fetch all styles applied to element. You could iterate over returned...
Maybe it isn't possible to change the color inside the checkbox square but you can trick as @gavgrif said. I just hover when you pass on the checkbox (not on...
Use inline CSS styles whenever possible (not <style> tags on the page, but style="" attributes). Use HTML attributes (bgcolor, width, height, etc) whenever possible in lieu of CSS styles as...
If I understood it right: .top-level-menu { ... position: absolute; top: 0; width: 100%; ... } Menu wrapper .top-level-menu is 100% wide but you need to correct the .top-level-menu...
I'm not sure which framework did you mean by saying that "some classes are define in the framework as:". In Less, you don't declare mixins the way you showed it....
In the code you provided, Chrome's Inspector reports "ffffcc" as an invalid property value for background-color in the div #wrapper. Adding the "#" in front of "ffffcc" makes the background-color...
You can embed web browser component into your Java Swing/JavaFX Desktop application that displays GUI built with HTML5+CSS+JavaScript. You can see an article that describes how to do this at...
as far as i know unless you build a composite control you can't add images to select menus. however, this article may help you: http://v2.easy-designs.net/articles/replaceSelect/...
If the animation is to complete in the first 25%, and you don't want the words to be fully transparant for too long, just reduce the periods during which the...
Correction in your HTML. You had same ID on input and same reference for attribute in label which will more likely not work. Updated HTML: <div ID="campaignDiv" runat="server"> <ul> <li>...
There is no need add !important until you are going to override already existing css line. So the code would be like this, #content img { max-width: 100%; height: auto...
So the question really is can a hidden/disabled border side be shown using pure CSS without repeating the border property twice? I suspect your real question is, as given...
A solution for layering your spans on top of each other would be to use position: relative; (which I see you already have there) and then modify the top margin...
your answer are here: just change my styles. http://codepen.io/leandroruel/pen/oyjhK HTML: <div id="navigacion"> <div class="topNaviagationLink"><a href="index.html">Home</a></div> <div class="topNaviagationLink"><a href="index.html">About</a></div> <div...
If available, using flex is the easiest. Apply these styles to the container in which you want to center your div: display: flex; align-items: center; justify-content: center; ...
Google uses a table to display their search box. The left and right columns have widths of 25% and the center column has a width of 50%. The search box...
IntelliJ IDEA relies on web frameworks and third-party deployment tools to perform this task. There is a feature request to perform such compilation internally, feel free to vote.
You dont neex ajax for this. You can put all the image urls in an JS array and when a then next button is clicked you just hide the current...
Thinking about this differently, I thought I could just have my python script run sass --watch source.sass:target.css and so I followed up how to run bash commands in python. Hence...