jQM - Resposnive design tutorial
by Dragan Gaić
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
<div data-role="page" id="index" data-theme="a">
<div data-theme="b" data-role="header">
<h3>
Second Example
</h3>
</div>
<div data-role="content" id="content">
<div class="inner-content">
<div class="image-container">
<img src="http://example.gajotres.net/images/lamborghini-test.jpg"/>
</div>
<div class="controls-container">
<label for="slider-1">Change image width:</label>
<input type="range" name="slider-width" id="slider-width" value="50" min="0" max="100"/>
<label for="slider-1">Change image height:</label>
<input type="range" name="slider-height" id="slider-height" value="50" min="0" max="100"/>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
.ui-content {
margin: 0 !important;
padding: 10px !important;
position : absolute !important;
top : 40px !important;
right : 0;
bottom : 0 !important;
left : 0 !important;
}
.inner-content {
width: 100%;
height: 100%;
}
.image-container, .controls-container {
width: 50%;
height: 100%;
float: left;
}
.image-container img {
width: 50%;
height: 50%;
}
/* 0 - 480px */
@media only screen and (max-width: 768px) {
.image-container, .controls-container {
width: 100%;
height: 50%;
}
}
JavaScript
$(document).on('pageinit', '#index', function(){
$(document).on( "slidestop", "#slider-width" ,function( event, ui ) {
$('.image-container img').css({'width':$(this).val() + '%'});
});
$(document).on( "slidestop", "#slider-height" ,function( event, ui ) {
$('.image-container img').css({'height':$(this).val() + '%'});
});
});