Home>Article>Web Front-end> How to add scroll bar in css

How to add scroll bar in css

王林
王林 Original
2021-07-12 16:48:05 5466browse

The way to add a scroll bar in css is to add the overflow attribute to the div and set the attribute value to scroll, such as [overflow: scroll;]. The overflow attribute specifies what happens when the content overflows.

How to add scroll bar in css

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

To add a scroll bar is actually very simple. There is an attribute overflow, which specifies what will happen if the content overflows the box of an element.

Let’s take a look at the attribute values:

visible Default value. The content will not be trimmed and will be rendered outside the element box.

hidden The content will be trimmed and the remaining content will be invisible.

scroll The content will be trimmed, but the browser will display scroll bars to view the remaining content.

auto If the content is trimmed, the browser displays scroll bars to view the remaining content.

inherit specifies that the value of the overflow attribute should be inherited from the parent element.

Example:

    php中文网(php.cn)  

overflow 属性

如果元素中的内容超出了给定的宽度和高度属性,overflow 属性可以确定是否显示滚动条等行为。

overflow: scroll:

php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!

overflow: hidden:

php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!

overflow: auto:

php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!

overflow: visible (默认):

php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!php中文网,梦开始的地方!

You can copy the above code locally and run it locally to see the effect.

Related video tutorial sharing:css video tutorial

The above is the detailed content of How to add scroll bar in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to set italics in css Next article:How to set italics in css