<分区>
标签 javascript jquery html css
<分区>
我有一个 div 元素:
<div class="page">
//some contents
</div>
CSS:
.page{
bottom: 0;
color: #1f1f21;
font-size: 17px;
font-weight: 400;
left: 0;
overflow: visible;
position: absolute;
right: 0;
top: 0;
}
使用 JavaScript 获取屏幕高度:
var page_height = screen.height;
alert(page_height);
如何将此 page_height
值应用于我的 .page
类?
(即)我需要为我的 page
类设置屏幕高度
例如,如果 screen.height = 405
我需要添加高度属性
height: 405px;
最佳答案
使用.height()
:
$('.page').height(page_height);
关于javascript - 如何将 JavaScript 值分配给 CSS 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28174748/