web前端实训day04——css部分知识回顾

web前端实训day04——css部分知识回顾

今日大纲

一、复合选择器
1.后代选择器:选择器选择器,会选中该标签内部所有符合条件的标签
2.子代选择器:选择器>选择器,会选中该标签内部所有的符合条件的儿子标签
3.兄弟选择器:选择器+选择器,会选中该标签下面紧挨着的第个标签
4.并集选择器:选择器,选择器,会选中,分隔的标签
5.伪类选择器:选择器:状态,
(1).link:未连接的
(2).visited:访问过的
(3).hover:鼠标悬停
(4).active:鼠标按住
(5).focus:聚焦的状态
二、emment语法
1. html的emment语法
1.1标签名加Tab键快速生成标签
1.2使用*生成多个相同的标签
1.3使用>生成父子关系
1.4使用+生成兄弟关系
1.5使用.和#生成类名或者id名的标签
1.6使用{}生成带有文字的标签
2. css的emment语法: 首字母简写

代码示例

复合选择器

后代选择器
<style>
         /* 
            后代选择器: 选择器 选择器
            后代:在该元素内部的元素,都是元素的后代,不管存在多少级 
         */
        .parent div {
            color: red;
        }
        
        .parent h1 {
            color: blue;
        }
</style>
<body>
    <div class="parent">
        <div>我是后代div1</div>
        <div>我是后代div2</div>
        <h1>我是后代h11</h1>
        <h1>我是后代h12</h1>
        <div>
            你好
            <h1>这个是孙子辈的h1</h1>
        </div>
    </div>
</body>
子代选择器
<style>
        /* 子代选择器: 选择器>选择器 */
        .parent>div {
            color: red;
        }
</style>
<body>
    <div class="parent">
        <h1>我是h1</h1>
        <h1>我是h1</h1>
        <h1>我是h1</h1>
        <h1>我是h1</h1>

        <div>
            <h1>我是h1</h1>
        </div>
    </div>   
</body>
兄弟选择器
    <style>
        /* 
            兄弟选择器:选择器+选择器
            注意事项:兄弟指的是:该标签下面的第一个紧挨着的标签 
        */
        /* .base+h1 {
            color: red;
        } */

        .base+p {
            color: red;
        }
    </style>
<body>
    <h1>第一个h1标签</h1>
    <h1 class="base">第二个h1标签</h1>
    <h1>第三个h1标签</h1>
    <h1>第四个h1标签</h1>
    <p>p标签</p>
</body>
并集选择器
	<style>
        /* 并集选择器:选择器,选择器 */
        div,h1,p,span {
            color: red;
        }     
    </style>
<body>
    <div>我是div</div>
    <h1>我是h1</h1>
    <p>我是p标签</p>
    <span>我是span</span>
</body>
伪类选择器
    <style>
        /* 
            伪类选择器: 选择器:状态 
            hover:鼠标悬停
            link:未访问的状态
            visited:访问过得状态
            active:鼠标按下没有抬起的状态
            focus:焦点聚集状态 
        */
        .a1:hover{
            color: red;
        }
        .a2:link {
            color: black;
        }

        .a3:visited {
            color: green;
        }

        .a4:active {
            color: orchid;
        }

        .input:focus {
            border: 5px solid red;
        }
    </style>
<body>

    <a href="#" class="a1">第一个链接</a>
    <br>
    <a href="##" class="a2">第二个链接</a>
    <br>
    <a href="###" class="a3">第三个链接</a>
    <br>
    <a href="####" class="a4">第四个链接</a>

    <input type="text" class="input">
    
</body>

emment语法演示

	<style>
        /* 首字母简写 */
        h1 {
            width: 200px;
            height: 200px;
        }
    </style>
<body>
    <!-- 标签名+Tab:快速生成标签 -->
    <h1></h1>

    <!-- 使用*生成多个标签 -->
    <h1></h1>
    <h1></h1>

    <!-- 使用>生成父子关系 -->
    <ul>
        <li></li>
    </ul>

    <!-- 使用+生成兄弟关系 -->
    <div></div>
    <h1></h1>

    <!-- 使用.生成带有class类的标签 -->
    <div class="header"></div>

    <!-- 使用#生成带有demo类的标签 -->
    <div id="demo"></div>

    <!-- 使用{}来生成带有文字的标签 -->
    <h1>我是h1</h1>
    
</body>

案例一:悬停显示

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例一plus</title>
    <style>
        .content {
            border: 1px solid black;
            width: 100px;
        }
        .content div {
            width: 100px;
            height: 100px;
            background-color: red;
            display: none;
        }

        .content:hover div{
           
            display: block;
        }
        
        
    </style>
</head>
<body>
    <div class="content"> 
        <a href="">悬停显示</a>
        <div>
            你看到我了
        </div>
    </div>
</body>
</html>

案例—登录

效果图在这里插入图片描述

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录界面</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        body {
            background-color: #f5f5f5;
            color: white;
            font-size: 12px;
        }

        a {
            text-decoration: none;
            color: white;
        }
        .header {
            height: 102px;
            width: 950px;
            margin: 0 auto;
        }

        .header p {
            line-height: 90px;
            color: #4f4e4d;
            font-size: 24px;
            background-image: url(images/logo.png);
            background-repeat: no-repeat;
            background-position: left center;
            text-align: right;
            width: 280px;
        }
         /* 登录区域开始 */
        .content {
            background-image: url(images/regist.png);
            background-repeat: repeat-x;
            height: 560px;
        }

        .login {
            width: 280px;
            height: 296px;
            
            float: right;
            margin-right: 122px;
            margin-top: 122px;
            padding: 10px;
            box-sizing: border-box;
            background-color: rgba(0,0,0,0.3);
        }

        .title {
            height: 40px;
            border-bottom: 1px solid #f0f0f0;
            line-height: 40px;
           
        }

        .title>span {
            font-size: 18px;
        }

        .title a {
            float: right;
            
        }
        
        .username, .password {
            height: 85px;
        }

        .username input {
            width: 100%;
            height: 38px;
            margin-top: 15px;
            border: none;
            padding-left: 10px;
            box-sizing: border-box;
            background-image: url(images/username.png);
            background-repeat: no-repeat;
            background-position: 95% center;
            
        }

        .password input  {
            width: 100%;
            height: 38px;
            margin-top: 15px;
            border: none;
            padding-left: 10px;
            box-sizing: border-box;
            background-image: url(images/username.png);
            background-repeat: no-repeat;
            background-position: 95% center;
        }


        .choose a{

            margin-left: 105px;
        }

        .login-btn {
            margin-top: 10px;
        }

        .login-btn button {
            width: 100%;
            height: 37px;
            color: white;
            /* background-color: #27b0f6; */
            background-color: #1aa9f2;
            border: none;
            font-weight: 700;
        }
        /* 登录区域结束 */
        
        
        .footer {
            height: 900px;
        }

    </style>
</head>
<body>
    <!-- 头部开始 -->
    <div class="header">
        <p>欢迎登录</p>
    </div>
    <!-- 头部结束 -->
    <div class="content">
        <div class="login">
             <div class="title">
                 <span>登录学子商城</span>
                 <a href="#">新用户注册</a>
             </div>
             <div class="username">
                 <input type="text" placeholder="请输入您的用户名">
             </div>
             <div class="password">
                <input type="password" placeholder="请输入您的密码">
             </div>
             <div class="choose">
                <input type="checkbox" id="box-login">
                <label for="box-login">自动登录</label>
                <a href="#">忘记密码?</a>
            </div>
            <div class="login-btn">
                <button>登录</button>                  
            </div>
        </div>
    </div>

    <div class="footer">

    </div>
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值