问答详情
源自:12-2 我要独占一行 - 块级元素

块级元素 的高度、宽度、行高 以及 顶 和 底边距 怎么设置???希望能写一下代码,标准的格式??

div,p,h1{background:pink;}
</style>
</head>
<body>
<h1>hkds</h1>
<div>div1</div>
<div>div2</div>
<p>段落1段落1段落1段落1段落1</p>
</body>
</html>

提问者:geguangfu 2016-09-01 17:44

个回答

  • 漫漫编程路丶
    2016-09-01 18:07:47
    已采纳

    这里拿<h1>块级元素来说明

    <style type="text/css">

         h1{

        width:200px;/*宽*/

        height:100px;/*高*/

        padding-top:10px;/*行高*/

        margin-top:5px;/*顶边距*/

        margin-bottom:5px;/*底边距*/

    }

    <style>

  • chen_f
    2016-09-01 18:13:38

    57c7ff1400010e6205000276.jpg

    57c7ff150001d21303630092.jpg

    -top(上)-bottom(下)-left(左)-right(右)

  • 夏默默
    2016-09-01 18:10:28

    <style type="text/css">

         h1{

        width:200px;/*宽*/

        height:100px;/*高*/

        padding-top:10px;/*行高*/

        margin-top:5px;/*顶边距*/

        margin-bottom:5px;/*底边距*/

    }

    <style>