Home > Article > Web Front-end > How to set scroll bar in DIV
In the actual operation process, we know that many DIVs are not enough to display all the content, so the scroll bar must be set. Today I will teach you how to set the scroll bar of DIV.
Set the scroll bar for the div and set its horizontal scroll bar and vertical scroll bar styles. The required CSS styles are overflow-y and overflow-x to set the right and bottom scroll bar effects of the div box object. At the same time, you can also use CSS styles to hide the scroll bar of the html frame iframe. I will introduce it to you next.
1. Basic understanding of CSS - TOP
<!DOCTYPE html> <html> <head> <meta charset="gb2312" /> <title>div滚动条 在线演示 www.divcss5.com</title> <style> .divcss5-a,.divcss5-b{ width:150px; height:100px; float:left; border:1px solid #F00} .divcss5-b{ margin-left:10px;overflow-y:scroll; overflow-x:scroll;} /* css注释说明:设置第二个盒子与第一个盒子间距为10px,并设置了横纵滚动条样式 */ </style> </head> <body> <div class="divcss5-a">哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈 哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈 哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊</div> <div class="divcss5-b">哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈 哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈 哈哈哈哈啊哈哈哈哈哈哈啊哈哈哈哈哈哈啊</div> </body> </html>In order to observe the effect, we set the same CSS style and the same text content for both DIV boxes. X and y (horizontal and vertical scroll bar styles) are set for ".divcss5-b". The first box ".divcss5-a" has too much content and overflows the DIV box, and the second The box has a scroll bar style set, so there is no overflow. A pull-down scroll bar style appears on the right side (Y) of the vertical direction. Horizontally
The above is the detailed content of How to set scroll bar in DIV. For more information, please follow other related articles on the PHP Chinese website!