HTML <div> 标签

定义和用法

<div> 可定义文档中的分区或节(division/section)。

<div> 标签可以把文档分割为独立的、不同的部分。它可以用作严格的组织工具,并且不使用任何格式与其关联。

如果用 id 或 class 来标记 <div>,那么该标签的作用会变得更加有效。

用法

<div> 是一个块级元素。这意味着它的内容自动地开始一个新行。实际上,换行是 <div> 固有的唯一格式表现。可以通过 <div> 的 class 或 id 应用额外的样式。

不必为每一个 <div> 都加上类或 id,虽然这样做也有一定的好处。

可以对同一个 <div> 元素应用 class 或 id 属性,但是更常见的情况是只应用其中一种。这两者的主要差异是,class 用于元素组(类似的元素,或者可以理解为某一类元素),而 id 用于标识单独的唯一的元素。

[tabs]
[tab name=”div元素布局” active=”true”]

规定各个模块样式,DIV可不用加 width代表宽度,height代表高度 ,background代表背景颜色, float代表排序方式, clear 清除左右排序让footing显示。

    <style type="text/css">
    body{
        margin: 0px;
    }

        div#container{
            width:100%;
            height:1000px;
            background-color:darkgray;

        }
        div#heading{
            width: 100%;
            height: 10%;
            background-color: Bisque ;
        }
        div#content_menu{
            width: 30%;
            height: 80%;
            background-color:Cornsilk ;
            float: left;
        }
        div#content_body{
            width: 70%;
            height: 80%;
            background-color:FloralWhite ;
            float: left;
        }
        div#footing{
            width:100%;
            height:10%;
            background-color:HoneyDew ;
            clear:both;
        }
    </style>

内容主体

分为四个模块:title,菜单,主体,底部

<div id="container">
        <div id="heading"><a href ="https://www.cyrilstudio.top" >梦溪分享</a></div>
        <div id="content_menu">内容菜单</div>
        <div id="content_body">内容主体</div>
        <div id="footing">底部</div>
    </div>

布局样式-梦溪分享

[/tab]
[tab name=”完整代码”]

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>div 布局    </title>
    <style type="text/css">
    body{
        margin: 0px;
    }

        div#container{
            width:100%;
            height:1000px;
            background-color:darkgray;

        }
        div#heading{
            width: 100%;
            height: 10%;
            background-color: Bisque ;
        }
        div#content_menu{
            width: 30%;
            height: 50%;
            background-color:Cornsilk ;
            float: left;
        }
        div#content_body{
            width: 70%;
            height: 50%;
            background-color:FloralWhite ;
            float: left;
        }
        div#footing{
            width:100%;
            height:10%;
            background-color:HoneyDew ;
            clear:both;
        }
    </style>
</head>
<body>
    <div id="container">
        <div id="heading"><a href ="https://www.cyrilstudio.top" >梦溪分享</a></div>
        <div id="content_menu">内容菜单</div>
        <div id="content_body">内容主体</div>
        <div id="footing">底部</div>
    </div>


</body>
</html>

[/tab]
[/tabs]

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注