
为什么不出现滚动条? CSS
在网上搜索fixed与absolute的区别,看到一段代码,复制到本地后,用浏览器打开,却没有滚动条??<!DOCTYPEhtml><head><metahttp-equ...
在网上搜索fixed与absolute的区别,看到一段代码,复制到本地后,用浏览器打开,却没有滚动条??
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body {
height:1000px; /*让窗体出现滚动条*/
}
.fixed {
position: fixed;
left: 100px;
right: 100px;
top: 100px;
bottom: 100px;
width: auto;
height: auto;
border: 1px solid blue;
}
.absolute {
position: absolute;
left: 100px;
right: 100px;
top: 100px;
bottom: 100px;
width: auto;
height: auto;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="fixed">fixed定位</div>
<div class="absolute">absolute定位</div>
</body>
</html>
为什么下面这段就出现了滚动条呢?
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{width:100px; height:100px; background: green;}
#left{position:absolute; left:0; top:100px;}
#right{position:fixed; right:0; top:100px;}
</style>
</head>
<body style="height:1000px">
<div id="left">absolute</div>
<div id="right">fixed</div>
</body>
</html> 展开
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body {
height:1000px; /*让窗体出现滚动条*/
}
.fixed {
position: fixed;
left: 100px;
right: 100px;
top: 100px;
bottom: 100px;
width: auto;
height: auto;
border: 1px solid blue;
}
.absolute {
position: absolute;
left: 100px;
right: 100px;
top: 100px;
bottom: 100px;
width: auto;
height: auto;
border: 1px solid red;
}
</style>
</head>
<body>
<div class="fixed">fixed定位</div>
<div class="absolute">absolute定位</div>
</body>
</html>
为什么下面这段就出现了滚动条呢?
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{width:100px; height:100px; background: green;}
#left{position:absolute; left:0; top:100px;}
#right{position:fixed; right:0; top:100px;}
</style>
</head>
<body style="height:1000px">
<div id="left">absolute</div>
<div id="right">fixed</div>
</body>
</html> 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |