• h5css3_03练习


    基础案例

    01-轮播图进度条

    训练描述

    完成鼠标经过即可

    训练提示

    1. 添加背景图片,设置初始化样式
    2. 利用盒子,定位盒子的位置,设置li的宽和高
    3. 设置span的小高度,设置span的伪元素跟span一样大小,并且左下角对齐,宽度默认为0
    4. 当鼠标经过则给伪元素宽度

    操作步骤

    1. 创建index文件,新建css文件夹,创建base.css文件并初始化基本代码,新建images文件夹

    2. 创建index.css保存至css文件夹,首页html文件引入css样式

    3. 编写结构代码

      • 创建父盒子,设置嵌套的盒子

        	<div class="progress">
        		<ul>
        			<li>
        				<span></span>
        			</li>
        			<li>
        				<span></span>
        			</li>
        		</ul>
        	</div>
        
      • 设置默认的样式

        html, body {
            height: 100%;
        }
        
        body {
            background: url(../images/vivo-banner-z3ys-bg.jpg) no-repeat center top;
            background-size: cover; /*覆盖*/
            position: relative;
        }
        
        .progress {
            position: absolute;
            display: block;
             100%;
            height: auto;
            bottom: 40px;
            text-align: center;
        }
        
        .progress li {
            position: relative;
            display: inline-block;
             40px;
            height: 20px;
            margin: 0 4px;
            text-align: center;
            z-index: 3;
            cursor: pointer;
        }
        
        .progress li span {
            position: absolute;
             40px;
            height: 2px;
            left: 50%;
            margin-left: -20px;
            bottom: 0;
            background-color: rgba(0, 0, 0, .2);
            -webkit-transition: all .3s .1s ease-out;
            transition: all .3s .1s ease-out;
        }
        
      • 设置伪元素样式和鼠标经过样式

        .progress li span::after {
            content: "";
            position: absolute;
             0;
            height: 100%;
            left: 0;
            bottom: 0;
            background-color: #666;
            -webkit-transition: all .3s .1s ease-out;
            transition: all .3s .1s ease-out;
        }
        
        .progress li:hover span {
            height: 5px;
        }
        
        .progress li:hover span::after {
             100%;
            -webkit-transition: width 5s ease;
            transition: width 5s ease;
        }
        

    02- 热点新闻文字持续滚动

    训练描述

    这种方式一般叫做无缝滚动,通常需要两份内容,滚动停不下来

    训练提示

    1. 先进行基本的布局,将内容复制一份,排列在一行

    2. 声明动画,让第一份盒子出去后,马上就回来,并且运动速率是匀速地

    3. 引入动画,重复播放

    操作步骤

    ​ 1,创建基本的结构

        <div class="container">
            <div class="gonggao">
                <div class="gg-pic"></div>
                <div class="gg-text">
                    <div class="gg-info">
                        <p>从前有座山,山里有座庙,庙里有个页面找呀找不到 </p>
                        <p>从前有座山,山里有座庙,庙里有个页面找呀找不到 </p>
                    </div>
                </div>
            </div>
        </div>
    

    ​ 2,排版基本的样式

    * {
    	margin: 0;
    	padding: 0;
    }
    html,body {
    	 100%;
    	height: 100%;
    }
    .container {
        max- 640px;
        height: 100%;
        margin: 0 auto;
        background-color: #f8f8f8;
    }
    .gonggao {
        padding-top: 80px;
    }
    .gg-pic {
        float: left;
         100px;
        height: 40px;
        background-color: sandybrown;
    }
    .gg-text {
        margin-left: 100px;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
        font-family: 'Microsoft Yahei';
        overflow: hidden;
    }
    .gg-info {
         200%;
        position: relative;
        animation: gonggao 4s linear infinite;
    }
    .gg-info p {
        position: absolute;
        top: 0;
         50%;
    }
    .gg-info p:first-child {
        left: 0;
    }
    .gg-info p:last-child {
        left: 50%;
    }
    
    @keyframes gonggao {
        from {
        	transform: translateX(0);
        }
        to {
            transform: translateX(-50%);
        }
    }
    

    扩展案例

    03-防《迅雷》首页旋转图片

    训练描述

    ​ 1,导航底部的线,在鼠标经过的时候有一个以中间向两边打开的过渡

    ​ 2,首屏图片周围有旋转的图片

    训练提示

    1. 先完成导航,导航通过固定定位在最上面,鼠标经过大盒子还有背景颜色
    2. 设置基本的图片,加入其他图片后进行旋转

    操作步骤

    ​ 1,新建导航基本的结构

    <header>
    	<div class="header-inner clearfix">
    		<h1 class="xl-logo">
    			<img src="images/xl-logo2x.png" alt="">
    		</h1>
    		<ul class="xl-nav">
    			<li class="active"><a href="#">首页</a></li>
    			<li><a href="#">产品中心</a></li>
    			<li><a href="#">区块链</a></li>
    			<li><a href="#">广告服务</a></li>
    			<li><a href="#">关于我们</a></li>
    			<li><a href="#">投资者关系</a></li>
    		</ul>
    	</div>
    </header>
    

    ​ 2,创建导航CSS样式

    header {
    	position: fixed;
        z-index: 100;
        top: 0;
        left: 0;
        right: 0;
        -webkit-transition: .3s ease;
        transition: .3s ease;
    }
    
    header:hover {
    	background-color: rgba(0,0,0,.8);
    }
    
    .header-inner {
    	max- 1200px;
        margin: 0 auto;
    }
    
    .xl-logo {
        float: left;
        margin-top: 14px;
         78px;
        height: 37px;
    }
    
    .xl-logo img {
    	 100%;
    	height: 100%;
    }
    
    .xl-nav {
    	text-align: right;
    	white-space: nowrap;
    }
    
    .xl-nav li {
    	position: relative;
        display: inline-block;
        margin-left: 2.5%;
    }
    
    .xl-nav li a {
    	display: inline-block;
        font-size: 14px;
        color: #fff;
        padding: 0 10px;
        line-height: 64px;
    }
    
    .xl-nav li a::after {
    	opacity: 0;
        position: absolute;
        content: "";
        left: 0;
        right: 0;
        bottom: 0;
         100%;
        height: 2px;
        -webkit-transform: scaleX(0);
        -ms-transform: scaleX(0);
        transform: scaleX(0);
        -webkit-transition: all .4s ease;
        transition: all .4s ease;
        background-color: #fff;
    }
    
    .xl-nav li a:hover::after {
    	opacity: 1;
        -webkit-transform: scaleX(1);
        -ms-transform: scaleX(1);
        transform: scaleX(1);
    }
    
    .xl-nav li.active a::after {
    	opacity: 1;
        -webkit-transform: scaleX(1);
        -ms-transform: scaleX(1);
        transform: scaleX(1);
    }
    

    ​ 3,创建首屏图片的基本结构

    <div class="container">
    	<div class="home-inner">
    		<div class="home-inner-c">
    			<div class="home-inner-pro">
    				<div class="earth-box">
    					<i class="banner-earth"></i>
    				</div>
    				<div class="banner-line">
    					<i class="circle01"></i>
    					<i class="circle02"></i>
    				</div>
    			</div>
    		</div>
    	</div>
    </div>
    

    ​ 4,声明首屏样式和图片位置

    <header>
    	<div class="header-inner clearfix">
    		<h1 class="xl-logo">
    			<img src="images/xl-logo2x.png" alt="">
    		</h1>
    		<ul class="xl-nav">
    			<li class="active"><a href="#">首页</a></li>
    			<li><a href="#">产品中心</a></li>
    			<li><a href="#">区块链</a></li>
    			<li><a href="#">广告服务</a></li>
    			<li><a href="#">关于我们</a></li>
    			<li><a href="#">投资者关系</a></li>
    		</ul>
    	</div>
    </header>
    

    ​ 5,创建首屏图片基本样式

    .home-inner {
    	position: relative;
         100%;
        height: 1080px;
        overflow: hidden;
        margin-bottom: -152px;
        background-color: #080325;
        zoom: 0.6;
      	/*缩小当前的盒子*/
    }
    
    .home-inner-c {
    	position: relative;
        top: 50%;
        left: 50%;
        margin: -540px 0 0 -960px;
         1920px;
        height: 1080px;
        background-image: url(../images/banner_bg.jpg);
        background-repeat: no-repeat;
        background-position: center top;
    }
    
    .banner-earth {
    	position: absolute;
        top: 82px;
        left: 0;
        right: 0;
        display: block;
        margin: auto;
        background: url(../images/earth01.png) no-repeat;
         730px;
        height: 730px;
    }
    
    .banner-line {
    	position: absolute;
        top: 70px;
        left: 0;
        right: 0;
         750px;
        height: 750px;
        margin: auto;
    }
    /*   
         A>B 表示选择A元素的所有子B元素(只选择第一代)
         A B 表示选择A元素的所有子B元素(选择在A标签里面所有的B元素,不止第一代)
         A+B表示HTML中紧随A的B元素:用一个结合符只能选择两个相邻兄弟中的第二个元素
    */
    .banner-line > i {
    	position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        display: block;
        margin: auto;
    }
    

    ​ 6,创建两个旋转盒子的样式和动画

    .circle01 {
    	background-image: url(../images/spr_bannerPathway.png);
        background-position: -2436px 0px;
        background-repeat: no-repeat;
         719px;
        height: 719px;
        -webkit-animation: ani_line 30s linear infinite;
        animation: ani_line 30s linear infinite;
    }
    
    .circle02 {
    	background-image: url(../images/spr_bannerPathway.png);
        background-position: -2436px -724px;
        background-repeat: no-repeat;
         648px;
        height: 674px;
        animation: ani_line 3s steps(180) infinite reverse;
    }
    
    @keyframes ani_line {
    	0% {
    	    -webkit-transform: none;
    	    transform: none;
    	}
    	100% {
    	    -webkit-transform: rotate(360deg);
    	    transform: rotate(360deg);
    	}
    }
    
  • 相关阅读:
    New Year and Domino 二维前缀和
    java课堂作业(三)
    java课堂作业(二)
    java课堂作业(一)
    java听课笔记(四)
    java听课笔记(三)
    java听课笔记(二)
    java听课笔记(一)
    java零碎
    java继承中的构造方法
  • 原文地址:https://www.cnblogs.com/fly-book/p/12100193.html
Copyright © 2020-2023  润新知