Home > Web Front-end > HTML Tutorial > How to hide the scroll bar in html

How to hide the scroll bar in html

藏色散人
Release: 2023-01-04 09:34:04
Original
11155 people have browsed it

htmlHow to hide the scroll bar: First create an HTML sample file; then set the content area in the body, and put a p outside the content area; finally set the style of p to "overflow:hidden" that is Can.

How to hide the scroll bar in html

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, DELL G3 computer

HTML hides the scroll bar and has a scrolling effect

1. Problem description, see the picture below.

When no scroll bar appears, the width of the header and the content area are equal, but there is too much content in the content area, so the scrolling effect must be retained without the scroll bar appearing. .

2. Solution

Put a p in the outer layer of the content area, set the overflow:hidden style of p, and set the width of the content area to "100% 20px";

<p style="width:400px;height:400px;border:1px solid gray">
	<p style="height:40px;line-height:40px;background-color:yellow;text-align:center">头部</p>
	<p style="height:360px;width:400px;overflow:hidden">
        <!-- 内层带滚动效果的p,宽度比父级p宽20px,滚动条被父p隐藏了 -->
		<p style ="height:360px;width:420px;background-color:green;overflow-y:scroll">
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
			<p style="border-bottom:1px solid gray">哈哈哈</p>
		</p>
	</p>
</p>
Copy after login

Recommended study: "HTML Video Tutorial"

The above is the detailed content of How to hide the scroll bar in html. 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