Vertically Scrollable In Div Element Using CSS

My computer develop environment

1
2
3
4
5
6
7
$ sw_vers 
ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G29

Chrome
67.0.3396.99(64 bit)

Today I want to share a method that limit div height and view its content by scrolling if content ‘s length is too much for current screen height.

First your should make sure the height you want, and set it in div style

1
<div style="height:100%;">

Next, fixed it being vertical direction in the screen and make it can be scroll.
The core code is overflow-y: scroll;

At last, the complete code is as follow

1
<div style="overflow-y: scroll; height:100%;">
# css

Thank you for reading.
This post is copyrighted by Liyuliang’s Blog.
If reproduced, please indicate the source: Liyuliang’s Blog
This blog uses Creative Commons Attribution-NonCommercial-Share-Sharing 4.0 International License Agreement to license.


Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×