Home > Web Front-end > CSS Tutorial > How to hide drop-down scroll bar in css

How to hide drop-down scroll bar in css

王林
Release: 2023-01-06 11:13:12
Original
4585 people have browsed it

The way to hide the drop-down scroll bar in css is to add the overflow attribute, such as [overflow:hidden]. At this time, the drop-down scroll bar will be completely hidden. It should be noted that the overflow attribute will only work on block elements with a specified height.

How to hide drop-down scroll bar in css

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

In CSS, we can use the overflow attribute to control the addition of scroll bars in the corresponding element range when the content overflows the element box.

If we need to hide the scroll bar and display the scroll bar when the content overflows, we only need to set the overflow: auto style; if we want to completely hide the scroll bar, we only need to set overflow: hidden, but this way will cause the element content to be non-scrollable.

Note: The overflow attribute only works on block elements with a specified height.

For example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php.cn</title>
<style>
div {
    background-color: #eee;
    width: 200px;
    height: 50px;
    border: 1px dotted black;
    overflow: visible;
}
</style>
</head>
<body>

<div id="overflowTest">
<p>这里的文本内容会溢出元素框。</p>
<p>这里的文本内容会溢出元素框。</p>
<p>这里的文本内容会溢出元素框。</p>
</div>

</body>
</html>
Copy after login

Related video tutorial: css video tutorial

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template