兼容性好的overflow CSS清除浮动一例_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 08:55:54
Original
1265 people have browsed it

清除浮动似乎写css的都要用到,不过各大浏览器存在兼容性,这样我们这些CSSer们很头疼,为了一个清除浮动,甚至要写很多个代码来兼容。从实 践中摸索,找到一种简单的清除浮动的办法,不单使用简单,而且FF火狐、OPera、Chrome、IE8都支持,使用时只要为需要清浮动的标签加上 overflow属性即可。以下来一个完整的例子供参考:

CSS代码部分:

    ul{        list-style:none;        height:auto;       margin:0;p        adding:0;        background-color:#436973;        }        li{        float:left;        width:80px;        height:80px;        background-color:#83B1DF;        }        .demo{        clear:both;        border:1px solid #FF00FF;        margin-bottom:5px;        }       .overflow{        overflow:auto;        zoom:1;        background-color:#43FF73;        }        ul{        list-style:none;        height:auto;      margin:0;       padding:0;        background-color:#436973;       }        li{        float:left;        width:80px;        height:80px;        background-color:#83B1DF;        }        .demo{        clear:both;        border:1px solid #FF00FF;        margin-bottom:5px;       }        .overflow{        overflow:auto;       zoom:1;        background-color:#43FF73;       }
Copy after login

HTML代码部分如下:

<div class="demo">02    <ul class="overflow">        <li>1</li>        <li>2</li>        <li>3</li>       <li>4</li>        <li>5</li>        <li>6</li>        <li>7</li>       <li>8</li>        <li>9</li>        </ul>        </div>       <div class="demo">        <ul>        <li>1</li>        <li>2</li>        <li>3</li>        <li>4</li>        <li>5</li>        <li>6</li>        <li>7</li>        <li>8</li>        <li>9</li>        </ul>        </div>
Copy after login


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