博主信息
博文 7
粉丝 0
评论 0
访问量 5708
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
css基础知识--2019年4月25日10:58:08
MrLv的博客
原创
715人浏览过
  1. 写一个案例, 演示css中的选择器优先级(忽略js)



    实例

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <style>
        h1 {
            background-color: yellowgreen;
        }
        .id{
            background-color: aquamarine;
        }
        #id{
            background-color: blueviolet;
        }
    </style>
    <h1 id="" class="" title="" style="">标签颜色选择器</h1>
    <h1 id="" class="id" title="" style="">class颜色选择器</h1>
    <h1 id="id" class="id" title="" style="">id颜色选择器</h1>
    <h1 id="id" class="id" title="" style="background-color: brown">style颜色选择器</h1>
    </body>
    </html>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

  2. 写一个盒模型的简单案例,体会padding/border的简写规则


    实例

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>盒模型</title>
    </head>
    <body>
    <style>
        .h1{
            width: 500px;
            height: 300px;
        }
        .h2{
            width: 500px;
            height: 300px;
        }
        .a1{
            width: 200px;
            height: 200px;
            background-color: blueviolet;
            padding-top: 20px;
            padding-right: 4px;
            padding-bottom: 10px;
            padding-left: 10px;
            margin-top: auto;
            margin-right: 5px;
            margin-bottom: 5px;
            margin-left: auto;
        }
        .a2{
            width: 200px;
            height: 200px;
            background-color: green;
            padding:20px 4px 10px 10px;
            margin: auto 5px;
        }
        .b1{
            width: 200px;
            height: 200px;
            border-top-width: 10px;
            border-top-style: solid;
            border-top-color: pink;
            border-right-width: 10px;
            border-right-style: solid;
            border-right-color: pink;
            border-bottom-width: 10px;
            border-bottom-style: solid;
            border-bottom-color: pink;
            border-left-width: 10px;
            border-left-style: solid;
            border-left-color: pink;
            margin-top: auto;
            margin-right: 5px;
            margin-bottom: 5px;
            margin-left: auto;
        }
        .b2{
            width: 200px;
            height: 200px;
            border:10px solid pink;
            margin: auto 5px;
        }
    </style>
    <div class="h1">
    <div class="a1" style="float:left">
        <img src="http://www.php.cn/static/images/user_avatar.jpg">
        <p>内边距8行代码</p>
    </div>
    <div class="a2" style="float:left">
        <img src="http://www.php.cn/static/images/user_avatar.jpg">
        <p>内边距2行代码</p>
    </div>
    </div>
    <div class="h2" >
    <div class="b1" style="float:left">
        <img src="http://www.php.cn/static/images/user_avatar.jpg">
        <p>边框16行代码</p>
    </div>
    <div class="b2" style="float:left">
        <img src="http://www.php.cn/static/images/user_avatar.jpg">
        <p>边框2行代码</p>
    </div>
    </div>
    </body>
    </html>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

批改状态:未批改

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学