欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

html中div控件 以及float属性 以及 clear属性

程序员文章站 2024-01-30 21:51:40
...

输入:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="border: 1px solid red;">
        asdfasdf
    </div>
    
    <div style="height: 48px;
	    width:80%;
	    border: 1px solid red;
	    font-size: 16px;
	    text-align: center;
	    line-height: 48px;
	    font-weight: bold;">
    	asdf
    </div>
</body>
</html>

输出:

html中div控件 以及float属性 以及 clear属性

 输入:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="css/commons.css" />
</head>
<body>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
    <div class="c1 c2" style="color: pink">asdf</div>
</body>
</html>

输出:

html中div控件 以及float属性 以及 clear属性

输入:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .pg-header{
            height: 38px;
            background-color: #dddddd;
            line-height: 38px;
        }
    </style>
</head>
<body style="margin: 0">
    <div class="pg-header">
        <div style="width: 980px;margin: 0 auto;">
            <div style="float: left;">收藏本站</div>
            <div style="float: right;">
                <a>登录</a>
                <a>注册</a>
            </div>
            <div style="clear: both"></div>
        </div>
    </div>
    <div>
        <div style="width: 980px;margin: 0 auto;">
            <div style="float: left">
                Logo
            </div>
            <div style="float: right">
                <div style="height: 50px;width: 100px;background-color: #dddddd"></div>
            </div>
            <div style="clear: both"></div>
        </div>
    </div>
    <div style="background-color: red;">
         <div style="width: 980px;margin: 0 auto;">
             asdfsdf
         </div>
    </div>
    <div style="width: 300px;border: 1px solid red;">
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="width: 96px;height:30px;border: 1px solid green;float: left;"></div>
        <div style="clear: both;"></div>
    </div>
</body>
</html>

输出:

html中div控件 以及float属性 以及 clear属性