Отступ в зависимости от высоты окна браузера
Пытаюсь изменить css свойство div#stage в зависимости от высоты окна браузера. Подскажите, пожалуйста, где ошибка?
jQuery(document).ready(function () {
$('#stage').css('margin-top', ($(window).height()*0.2));
});
|
Цитата:
|
Или учись делать тестовые примеры...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1251' />
<script src='http://code.jquery.com/jquery-latest.js'></script>
<!--
<script src="https://code.angularjs.org/1.3.9/angular.min.js"></script>
<script src="https://code.angularjs.org/1.3.9/angular-route.js"></script>
-->
<style type='text/css'>
#stage {
width: 10px;
height: 10px;
border: 1px solid;
}
</style>
<script type='text/javascript'>
jQuery(document).ready(function () {
$('#stage').css('margin-top', ($(window).height()*0.2)+'px');
});
</script>
</head>
<body>
<div id='stage'></div>
</body>
</html>
|
| Часовой пояс GMT +3, время: 08:34. |