博主信息
博文 18
粉丝 0
评论 0
访问量 15566
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
盒子的基本各属性的用法和基本的选择器-0704
XXXX.的博客
原创
816人浏览过

1、盒子margin、padding、border的基本用法:①margin padding只有宽度属性,border不仅有宽度属性还有颜色、样式属性。② padding: 20px;代表上右下左宽度相同。padding:20px 30px;代表上下相同且为20px,左右相同为30px。

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>一切皆盒子</title>
    <link rel="stylesheet" href="static/css/xxxx1.css">
</head>
<body>
<div class="box1">
    <div class="box2"></div>
</div>
</body>
</html>


.box1 {
     width: 200px;
     height: 200px;
     background: blueviolet;
     padding: 20px;
     border-bottom-color: olivedrab;
     border-bottom-style: dashed;
     border-bottom-width: 20px;
     border: olive double 30px;
     border-radius: 170px;
     margin: 20px;
 }
.box2 {
    background-color: yellowgreen;
}

运行实例 »

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


2、选择器

①在各种选择其中后面的会覆盖前面的。

②伪类选择q器中:child注重位置,type注重类型

③在选择器的使用中,根据自己所设计的实际内容选择更适合、更简单的选择器在实际中是非常重要的。

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="static/css/sss.css">
    <title>选择器</title>
</head>
<body>
<ul>
    <li class="bg-green">1</li>
    <li id="bg-blue">2</li>
    <li >3</li>
    <li >4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
</ul>

<div>
    <p>李宇春</p>
    <li>张靓颖</li>
    <p>周笔畅</p>
</div>
<div>
    <p>易烊千玺</p>
    <li>雷佳音</li>
</div>
<form action="">
    <p>
        <label for="email">邮箱:</label>
        <input type="email" id="email">
    </p>
    <p>
        <label for="password">密码:</label>
        <input type="password" id="password">
    </p>
    <p>
        <input type="radio" id="week" name="save" value="7" >
        <label for="week">保存一周</label>
        <input type="radio" id="month" name="save" value="30" >
        <label for="month">保存一月</label>
    </p>
    <button>登录</button>
</form>
</body>
</html>



/*标签选择器*/
ul {
    margin-top: 0;
    margin-bottom: 0;
    padding-left: 0;
    /*border: 1px solid black;*/
}
/*元素选择器也称后代选择器*/
ul li {
    /*list-style: none;*/
    /*width: 50px;*/
    /*height: 50px;*/
    /*background-color: yellow;*/
    /*border: 1px black solid;*/
    /*text-align: center;*/
    /*line-height: 50px;*/
    /*border-radius: 50%;*/
    /*display: inline-block;*/
    /*margin-left: 5px;*/
    /*box-shadow: 2px 2px 2px #888888;*/
}

/*id选择器*/
#bg-blue {
    /*background-color: aqua;*/
}
/*类选择器*/
.bg-green {
    /*background-color: bisque;*/
}

/*属性选择器*/
li[id="bg-blue"] {
    /*border: 2px solid red;*/
}
/*群组选择器 常用语初始化*/
#bg-blue,.bg-green {
    /*border: 2px solid blue;*/
}


/*#bg-blue + .bg-green {*/
    /*background-color: palevioletred;*/
/*}*/
/*兄弟选择器*/
/*#bg-blue ~ *{*/
    /*background-color: palevioletred;*/
/*}*/



/*!*伪类选择器*!子元素选择器*/
ul :first-child {
    /*background-color: red;*/
}
ul :last-child {
    /*background-color: red;*/
}
ul :nth-child(odd) {
    /*background-color: yellowgreen;*/
}
ul :nth-child(even) {
    /*background-color:black;*/
}
/*位置*/
ul :nth-last-child(3){
    /*background-color: yellowgreen;*/
}
/*类型*/
ul  li:nth-of-type(5) {
    /*background-color: bisque;*/
}

div:first-of-type :nth-child(3){
    /*background-color: yellowgreen;*/
}
div :nth-child(2) {
    /*background-color: #888888;*/
}
/*表单*/
/*选择能够使用的*/
form :enabled{
    /*background-color: yellowgreen;*/
}
form :focus {
    background-color: bisque;
}

    button :hover{width: 60px;
    height: 50px;
    background-color: black;
    border: none;
    border-radius: 6px;
    box-shadow: 5px 3px 5px #888888;
    color: white;
}

运行实例 »

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



批改状态:合格

老师批语:写得非常的完整, 规范,看来你对这些知识点的基本内容掌握了
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系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+教程免费学