Scroll bars appear in cells or layers

Source: Internet
Author: User
Cell

How scroll bars appear in cells or layers

Solution Idea:

This is done primarily by setting the CSS properties of the elements overflow (including overflow-x and overflow-y).

Specific steps:

1. Automatically appear horizontal scroll bar:

<div style= "Width:200;height:200;overflow-x:auto" >
<script>
Make an element appear in a horizontal scroll bar
document.write (The new Array.) Join ("! "))
To make an element appear in a vertical scroll bar
document.write (The new Array.) Join ("! <br> "))
</script>
</div>

2. Vertical scroll bar appears automatically:

<div style= "Width:200;height:200;overflow-y:auto" >
<script>
Make an element appear in a horizontal scroll bar
document.write (The new Array.) Join ("! "))
To make an element appear in a vertical scroll bar
document.write (The new Array.) Join ("! <br> "))
</script>
</div>

3. Vertical and horizontal scroll bars appear automatically:

<div style= "Width:200;height:200;overflow:auto" >
<script>
Make an element appear in a horizontal scroll bar
document.write (The new Array.) Join ("! "))
To make an element appear in a vertical scroll bar
document.write (The new Array.) Join ("! <br> "))
</script>
</div>

Note: To make the element scroll horizontally, you must define the width of the element, and to make the element scroll vertically, you first define the height of the element.

Special Tips

The 3rd step of the code run as shown in Figure 1.7.1, you can see from the diagram, the div element width and height limit to 200x200, out of range of content will automatically cut off, and add scroll bar.

Figure 1.7.1 Force the element to appear scroll bars

Special Notes

This example is mainly the application of CSS attribute overflow. The overflow property includes Overflow-x and Overflow-y, and if you want the setting to take effect only for the X or y axes, you must use Overflow-x or overflow-y, and the x and Y axes will be in effect when you set up overflow. The optional parameter values for the overflow attribute are described:

Visible does not cut content nor does it add scroll bars. If you explicitly declare this default value, the object will be clipped to the size of the window or frame that contains the object. and the Clip property setting will fail.

Auto This is the default value for the body object and textarea. Cut the content and add scroll bars when needed.

Hidden does not display content that exceeds the size of the object.

Scroll always displays scroll bars.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.