---
title: "html中设置超出部分自动显示滚动条"
author: "txf2004"
date: "2013-02-01T23:12:00Z"
tags: []
slug: "html"
draft: false
lastmod: "2013-02-02T20:47:20Z"
id: 1784179
url: "https://txf2004.iteye.com/blog/1784179"
---

在html页面中，我们有时需要让div中的内容超出后自动显示滚动条，我们可以这样设置：

```
<div class="classlist">
        <div class="autoScroll">
            <asp:RadioButtonList ID="rblClasses" runat="server" DataTextField="className" DataValueField="classID"
                ForeColor="#FF4040">
            </asp:RadioButtonList>
            <br />
            <asp:ImageButton ID="imgSure" runat="server" ImageUrl="~/images/c_sure.jpg" />
            <asp:ImageButton ID="imgClose" runat="server" ImageUrl="~/images/c_close.jpg" />
        </div>
    </div>
```

然后，样式中这样设置：

```
<style type="text/css">
        .classlist
        {
            width: 300px;
            height: 20px;
        }
        .autoScroll
        {
        	width:300px;
        	height:100px;
            overflow:auto;           
        }
        #rblClasses
        {
            margin-left: 20px;
        }
</style>
```

设置后，当radiobutton中显示的内容超出最外围的div时，将自动显示滚动条，即嵌套div