为什么这不能在窗户的骑行侧创建一个垂直的5px宽的酒吧?
<html>
<head runat="server">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#scrollBar").css({
height: $(window).height,
width: 5,
position: "absolute",
top: 0,
left: $(window).width - 5,
margin: 0
});
});
</script>
</head>
<body>
<div id="scrollBar" style="background-color: Red">test
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
请改用:
我发现了几个问题:
$(window).height,使用$(window).height()而不是left: $(window).width - 5,使用right: 0
$(document).ready(function() {
$("#scrollBar").css({
height: $(window).height(),
width: 5,
position: "absolute",
top: 0,
right: 0,
margin: 0
});
});
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
1484 次 |
| 最近记录: |