CSS笔记

CSS

<html>
<meta charset="UTF-8">
<head>
    <style type="text/css">
        /*标签样式表*/
        p{
            color: red;
        }
        /*类样式*/
        .f20{
            font-size: 20px;
        }
        /*id样式*/
        #p4{
            background-color: #1c7bcb;
            font-size: 25px;
            font-weight: bolder;
            font-style: italic;
            font-family: "微软雅黑";
        }
        div p{
            color: #1430e3;
        }
        div .f32{
            font-size: 32px;
            font-family: "黑体";
        }
    </style>
</head>
<body>
    <p><font color="red">这是段落1</font> </p>
    <p>这是段落2</p>
    <p class="f20">这是段落3 </p>
    <p id="p4">这是段落4 </p> <!--id 属性在整个html中保持唯一-->
    <div>
        <p><span style="font-size: 60px;color: red">hello</span></p>
        <span class="f32">word</span>
        <p class="f32">!!!</p>
    </div>
</body>
</html>
  1. 为什么需要css
  2. css的分类:标签样式表、类样式表、ID样式表 可以查样式表中文手册
  3. CSS从位置上的分类:嵌入式样式表,内部样式表,外部样式表

外部css的内容 css-demo01.css

/*id样式*/
#p4{
    background-color: #1c7bcb;
    font-size: 25px;
    font-weight: bolder;
    font-style: italic;
    font-family: "微软雅黑";
}
div p{
    color: #1430e3;
}
div .f32{
    font-size: 32px;
    font-family: "黑体";
}

引用外部的css样式

<link rel="stylesheet" href="css-demo01.css">

盒子模型

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style type="text/css">
        #div1{
            width: 400px;
            height: 400px;
            background-color: #5ccb32;

            /*border 边框样式*/
            border-width: 4px; /*边框粗细*/
            border-style: solid;/*边框样式:solid实线,*/
            border-color: blue;
        }
        #div2{
            width: 200px;
            height: 200px;
            background-color: #8e3d82;
            /*margin-top: 100px;*/
            /*margin-left: 100px;*/
            margin: 100px;
        }
    </style>

</head>
<body>
    <div id="div1">
        <div id="div2">&nbsp;</div>
    </div>
</body>
</html>

CSS布局

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style type="text/css">
        body{
            margin: 0;
            padding: 0;
        }
        #div1{
            width: 200px;
            height: 50px;
            background-color: #5ccb32;

            /*绝对定位*/
            position: absolute;
            left:100px;
            top: 100px;
        }
        #div2{
            width: 200px;
            height: 50px;
            background-color: #cb327f;

            /*相对定位*/
            position: relative;
            float: right;
            margin-right: 20px;
        }
        #div3{
            height: 50px;
            background-color: #325dcb;
        }
    </style>
</head>
<body>
    <div id="div1">&nbsp;</div>
    <div id="div2">&nbsp;</div>
    <div id="div3">&nbsp;</div>
</body>
</html>

水果库存静态页面

css-demo02.css

body{
  margin: 0;
  padding: 0;
  background-color: #808080;
}
div{
    position: relative;
    float: left;
}

#div_container{
    width: 80%;
    height: 800px;
    border: 1px solid blue;
    margin-left: 10%;
    float: left;
    background-color: #9ab291;
}
#tbl_fruit{
    width: 1200px;
    /*设置行高*/
    line-height: 28px;
}
#tbl_fruit,#tbl_fruit tr,#tbl_fruit th,#tbl_fruit td{
    border: 1px solid gray;
    /* 边框合并*/
    border-collapse: collapse;
    /*文本居中*/
    text-align: center;
    /*设置字体*/
    font-size: 16px;
    font-family: "黑体";
    font-weight: lighter;
    color: threeddarkshadow;

}
.w20{
    width: 20%;
}

html

 <html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css-demo02.css">
</head>
<body>
    <div id="div_container">
        <div id="div_fruit_list">
            <table id="tbl_fruit">
                <tr>
                    <th>名称</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>小计</th>
                    <th>操作</th>
                </tr>
                <tr>
                    <td>苹果</td>
                    <td>100</td>
                    <td>5</td>
                    <td>500</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>香蕉</td>
                    <td>100</td>
                    <td>5</td>
                    <td>500</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>鸭梨</td>
                    <td>100</td>
                    <td>5</td>
                    <td>500</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>西瓜</td>
                    <td>100</td>
                    <td>5</td>
                    <td>500</td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td>总计</td>
                    <td colspan="4">2500</td>
                </tr>
            </table>
        </div>
    </div>
</body>
</html>
名称单价数量小计操作
苹果1005500 
香蕉1005500 
鸭梨1005500 
西瓜1005500 
总计2500
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值