选中input的时候为什么要把div的图片换掉?
就是下面这句,为什么要换掉背景图片?这样的话,把图片偏出的时间改成0.5S,偏入的时间改成5S。会看到下面已经有换好的图片了呀?
1 2 3 4 | .cr-container input.cr-selector-img -1: checked~.cr-bgimg, .cr-bgimg div span:nth-child( 1 ) { background : url (../images/ 1 .jpg); } |
还有就是,为什么我把偏入偏出的时间全部改成5S,进入页面的前5秒,不会出现动画效果,过了5S才会出现呢?
17
收起
正在回答 回答被采纳积分+1
2回答
疯狂机械人偶
2017-08-16 22:25:17
完整CSS代码如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | .cr-bgimg div span { width : 100% ; height : 100% ; position : absolute ; left : -150px ; top : 0 ; z-index : 2 ; text-indent : -9999px ; background-repeat : no-repeat ; transition: left 5 s ease-in-out; } .cr-container input.cr-selector-img -1: checked~.cr-bgimg, .cr-bgimg div span:nth-child( 1 ) { background : url (../images/ 1 .jpg); } .cr-container input.cr-selector-img -2: checked~.cr-bgimg, .cr-bgimg div span:nth-child( 2 ) { background : url (../images/ 2 .jpg); } .cr-container input.cr-selector-img -3: checked~.cr-bgimg, .cr-bgimg div span:nth-child( 3 ) { background : url (../images/ 3 .jpg); } .cr-container input.cr-selector-img -4: checked~.cr-bgimg, .cr-bgimg div span:nth-child( 4 ) { background : url (../images/ 4 .jpg); } .cr-bgimg div:nth-child( 1 ) span { background-position : 0 0 ; } .cr-bgimg div:nth-child( 2 ) span { background-position : -150px 0 ; } .cr-bgimg div:nth-child( 3 ) span { background-position : -300px 0 ; } .cr-bgimg div:nth-child( 4 ) span { background-position : -450px 0 ; } .cr-container input:checked~.cr-bgimg div span { animation: slideOut . 5 s ease-in-out; } @keyframes slideOut { from { left : 0 ; } to { left : 150px ; } } .cr-container input.cr-selector-img -1: checked~.cr-bgimg div span:nth-child( 1 ), .cr-container input.cr-selector-img -2: checked~.cr-bgimg div span:nth-child( 2 ), .cr-container input.cr-selector-img -3: checked~.cr-bgimg div span:nth-child( 3 ), .cr-container input.cr-selector-img -4: checked~.cr-bgimg div span:nth-child( 4 ) { z-index : 10 ; left : 0 ; animation: none ; } |
相似问题
登录后可查看更多问答,登录/注册
HTML5与CSS3实现动态网页 2018
- 参与学习 1887 人
- 提交作业 4643 份
- 解答问题 5760 个
有HTML和CSS基础,却不知道如何进阶?本路径带你通过系统学习,完成从“会做网页”到“做出好的动态网页”的蜕变,迈出成为前端工程师的第一步。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧