< body> with overflow:scroll的行为不如预期 [英] <body> with overflow:scroll not behaving as expected
本文介绍了< body> with overflow:scroll的行为不如预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
查看以下图片和代码:
<!doctype html>
<html>
<head>
<style>
body {
border: 1px solid red;
padding: 20px;
overflow: scroll;
}
</style>
</head>
<body></body>
</html>
overflow:scroll
元素,但< body>
元素不占用整个网页,滚动条有什么问题?
The overflow: scroll
inserts scroll bars inside the element, but the <body>
element doesn't occupy the entire webpage, what is wrong with the scroll bars?
感谢
推荐答案
body
特例。应用于 body
标签的大多数样式规则适用于整个窗口,而不管 body
的大小是多少。对于你想要的行为(框中的滚动条),你需要使用 div
或其他一些块级别的元素在身体
。
The body
tag is kind of a special case. Most style rules applied to the body
tag apply to the whole window, regardless of tho body
's "size". For the behavior you want (a scrollbar inside a box), you'll need to use a div
or some other block-level element inside of the body
.
这篇关于< body> with overflow:scroll的行为不如预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文