Reputation: 1669
I have to add image on the header and background . Is it possible to set the image automatically resizing according to the screen orientation (portrait and Landscape). I set the image in portrait resolution , But when i change the screen to Landscape the image not resized. Can anyone give me some guidelines?
Upvotes: 4
Views: 16708
Reputation: 11
i use this css3 rule:
@media (orientation: landscape) {
#home-feature span {
display : inline-block;
}
}
more info: http://www.w3.org/TR/css3-mediaqueries/
Upvotes: 1
Reputation: 1946
It's recommended to use CSS3 media queries as the jQuery mobile orientation classes are deprecated: http://jquerymobile.com/demos/1.0b2/docs/api/mediahelpers.html
For a demo of CSS3 media queries: http://www.webdesignerwall.com/demo/media-queries/
Upvotes: 2
Reputation: 13052
Support for this is built into jQuery Mobile. There are two Orientation Classes which are present depending on the current screen orientation:
.portrait {
/* portrait orientation changes go here! */
}
.landscape {
/* landscape orientation changes go here! */
}
Or if you want a javascript event you can bind to orientationchange.
Upvotes: 6
Reputation: 3077
I don't think there are events that get triggered when the phone goes for landscape to portrait.You can however write a custom function to find out the current orientation. Write the following code on window.resize event.
$(window).resize( function(){
var height = $(window).height();
var width = $(window).width();
if(width>height) {
// Landscape
$("#img").attr("src","landscapeurl");
} else {
// Portrait
$("#img").attr("src","portraiturl");
}
});
code from Here
Upvotes: 5