CSS属性和盒子模型

CSS属性

1.字体、文本
(1)font-size:字体大小
(2)color:文本颜色
(3)text-align:对齐方式
(4)line-height:行高
2.背景
(1)background
3.边框
(1)border:设置边框
4.尺寸
(1)width:宽度
(2)height:高度

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>属性</title>
    <style>
        p{
            color: red;
            font-size: 30px;
            text-align: center;
            line-height: 100px;
            /*
                border 边框
             */
            border: 1px solid red;
        }
        div{
            border: 1px solid red;
            width: 200px;
            height: 200px;
            background: url("img/logo.jpg") no-repeat center;
        }
    </style>
</head>
<body>

    <p>字体属性</p>

    <div>aaaaaaaaaa</div>
</body>
</html>

 

 

 

 

 

 

 

 

 

 

 

 

CSS盒子模型

盒子模型:控制布局

  margin:外边距

  padding:内边距

    默认情况下内边距会影响这个和的大小

    box-sizing: border-box;设置盒子属性,让width和height就是最终盒子的大小

  float:浮动

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>属性</title>
    <style>
        div{
            border: 1px solid red;
            width: 100px;
        }
        .div1{
            width: 100px;
            height: 100px;
            /*外边距*/
            margin: 50px;
        }
        .div2{
            width: 200px;
            height: 200px;
            /*内边距*/
            /*
                设置盒子属性,让width和weight就是最终最重盒子
             */
            /*padding: 50px;*/
            box-sizing: border-box;
        }
        .div3{
            float: left;
        }
        .div4{
            float: left;
        }
        .div5{
            float: right;
        }
    </style>
</head>
<body>


    <div class="div2">
        <div class="div1"></div>
    </div>

    <div class="div3">aaaaa</div>
    <div class="div4">bbbbb</div>
    <div class="div5">ccccc</div>

</body>
</html>

 

posted @ 2022-08-01 16:27  xjw12345  阅读(49)  评论(0)    收藏  举报