overflow-y: auto
时间: 2023-09-02 14:11:55 浏览: 117
overflow:auto的用法详解
The CSS property `overflow-y: auto` sets the overflow behavior of the vertical axis of an element's content. When the content of an element exceeds its height limit, this property determines whether the browser should show a vertical scroll bar or not.
When `overflow-y` is set to `auto`, a vertical scroll bar will only appear if the content within the element overflows its height limit. If the content fits within the element's height limit, no scroll bar will be displayed.
Here's an example of `overflow-y: auto` in action:
```css
.container {
height: 200px;
overflow-y: auto;
}
```
In this example, the `.container` element has a height limit of 200 pixels. If the content within the container exceeds this limit, a vertical scroll bar will appear. If the content fits within the height limit, no scroll bar will be displayed.
Overall, `overflow-y: auto` is a useful CSS property for controlling the overflow behavior of an element's content on the vertical axis.
阅读全文