How to display image height according to device css - javascript

The problem is with my image. The img height is 1500px. That need to scroll down. I want the height to be as the height of the device display, like mobile and computer display.
img{
width:100%;
height:auto;
}

make the height also 100%
img{
width:100%;
height:100%;
}

Put the image in a wrapper with height: 100%;;
add same height: 100%; to the .img tag.
DEMO

Related

resizing element with jquery breaks 100% height

I have a sidebar that has this css:
background:#164272;
position:absolute;
left:0px;
top:70px;
width:250px;
height:100%;
And with jquery im showing a table that by default was hidden and is only shown when clicking an element.
But when i show the element on smaller sized screens it pretty much breaks the 100% height. here's an image
How can i prevent it from breaking the 100%?
Thank you
Try height 100% html and body. % height relative value. So it must need standard height value. in this time html, body is the standard.
And don't forget DOCTYPE declaration.
html, body
{height: 100%;
overflow:hidden;}
#yourDiv{
background:#164272;
position:absolute;
left:0px;
top:70px;
width:250px;
height:100%;
}
http://jsfiddle.net/under_09/4bs4r0y5/
If 100% height of the side bar is what you want at all screen resolution then why not
.sidebar {
top : 0;
bottom:0;
left :0;
}
Full fledged demo here
please note that since your width is defined in PX , is't not exactly going to be resposive , on that note checkout min-width and max-width.

css style to set minimum width of div else according to dynamic content

How can i set minimum width for div . My problem is i am dynamically loading content in a div some time it is large and some time it is small.
if it is small then behind div becomes invisible so i want to avoid that . and set div to minimum equal to parent div height or if content is more than auto ??
CSS::
#middle_overlay
{
position:absolute;
/*border:2px solid #008080;
background-color:#CCCCCC;*/
background-image:url(../images/bg2.jpg);
background-repeat:no-repeat;
background-size:100% 100%;
height:auto;
width:100%;
display:none;
}
Would min-width:xxx; work for you?
The min-width CSS property is used to set the minimum width of a given
element. It prevents the used value of the width property from
becoming smaller than the value specified for min-width.
See here for further information
min-width - This prevents the value of the width property from becoming smaller than min-width. min-width:450px; or min-width:50em;
#middle_overlay
{
position:absolute;
/*border:2px solid #008080;
background-color:#CCCCCC;*/
background-image:url(../images/bg2.jpg);
background-repeat:no-repeat;
background-size:100% 100%;
height:auto;
width:100%;
display:none;
min-width:450px; //50em
}
Note: The value of the min-width property overrides both max-width and width.

How to stretch a div vertically to the footer, and stretch to fit content?

I've been trying to make a div stretch down to my footer, with limited success. I've tried using jQuery to do this but it has some issues:
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
$(window).resize(function(){
var height = $(this).height() - $("#banner-wrapper").height() - $("#footer-wrapper").height()
$('#content').height(height);
})
$(window).resize(); //on page load
});//]]>
</script>
This stretches the div down to the footer, but the problem is, it bases the height of of the window size. If your content extends past the fold, the #content div doesn't stretch to fit the content.
http://matthewdail.com/staging/
Here you can see the jQuery doing it's job and stretching the #content div perfectly, but it doesn't extend to fit the content.
I've also tried some of the more common css tricks like:
html,body{
height:100%;
}
#content{
width:100%;
margin:0 auto -120px;
float:none;
min-height:100%;
height:auto !important;
height:100%;
}
I've searched everywhere but can't find a solution to this. Anyone have any ideas?
Try this layout and see if it works for you.
http://jsfiddle.net/TCdsK/14/
I have updated the fiddle to make the layout something similar to what you have,
http://jsfiddle.net/TCdsK/16/
hope this helps
edit: Make sure all the columns are of the same height
http://jsfiddle.net/TCdsK/21
Are you wanting the content div to extend down so that it pushes the footer to the bottom of the window? You'd be better off using something like this:
html {
position: relative;
min-height: 100%;
}
body {
margin: 0 0 100px; /* bottom = footer height */
}
footer {
position: absolute;
left: 0;
bottom: 0;
height: 100px;
width: 100%;
}
If the body doesn't contain enough content the footer will still stay at the bottom. Demo here.

how to make my images responsive?

Hi all using twitters bootstrap: http://twitter.github.io/bootstrap/base-css.html#tables
I am wandering how I can stop this happening: http://img823.imageshack.us/img823/6606/screenshotfrom201306071.png
I want the images to resize with the window until it gets bumped up above the text from bootsrap.
Link for it: http://www.prxa.info/articles/category/1 User: test.prxa. pass: test
I NEED images to have a max of 350px here as some images people include are massive and have to be resized to not mess it all up.
Here is my custom css for the thumbnail area and the images inside:
.thumbnail
{
width: 350px;
height: 220px;
display: table-cell;
vertical-align: middle;
}
img.tagline-img
{
max-width: 350px;
max-height: 220px;
}
Not the best responsive technique but it will make it fit
Just use
img.tagline-img {
width:100%;
}
Just tested on your site
taken from bootstrap :
img{
border:0;
max-width:100%; /* Part 1:Set a maxium relative to the parent */
width:auto\9; /* IE7-8 need help adjusting responsive images */
height:auto; /* Part 2:Scale the height according to the width,
otherwise you get stretching */
-ms-interpolation-mode:bicubic
}

Filling a div with an image (ignoring proportions)

I'm trying to fill a parent <div> with an image, while completely ignoring proportions. I know that it will look ugly at certain dimensions, I just want to see if it's possible at this point. As you can see, the image is scaling, rather than stretching to my demands (Chrome): http://jsfiddle.net/qdzaw/61/
Unfortunately, all I can find online is how to do this while maintaining proportions :/
<img class="someimage" src="imgsrc" />
$(window).resize(function() {
$(".someimage").height($(".someimage").parent().height());
$(".someimage").width($(".someimage").parent().width());
});
i think i find your answer in this post: Stretch and scale a CSS image in the background - with CSS only
use a parent div element and this stylesheet:
div {
width: 100%;
height: 100%;
}
img {
width:100%;
height:100%;
}
div {
position:relative;
}
div img {
position:absolute;
top:0; left:0; right:0; bottom:0;
}

Categories