4、简单的一个盒子移动到另一个盒子,你用什么方式实现动画效果
- <style>
- *{margin:0;padding:0}
- html,body{
- height: 100%;
- }
- .box1{
- width: 100%;
- height:500px;
- background-color: red;
- }
- .box2{
- width: 100vw;
- height:500px;
- background-color: green;
- }
- style>
- <div class="box1">div>
- <div class="box2">div>750的设计图,20px为多少rem
- <style>
- *{margin:0;padding:0}
- div{
- float: left;
- }
- .box1{
- width: 200px;
- height:200px;
- background-color: red;
- }
- .box2{
- width: 100px;
- height:100px;
- background-color: green;
- transition: all linear 1s;
- }
- .box1:hover+.box2{
- transform: translateX(-100px);
- }
- style>
-
- <div class="box1">div>
- <div class="box2">div>
- <style>
- *{margin:0;padding:0}
- div{
- float: left;
- }
- .box1{
- width: 200px;
- height:200px;
- background-color: red;
- }
- .box2{
- width: 100px;
- height:100px;
- background-color: green;
- animation: mover linear 1s;
- }
- @keyframes mover{
- 0%{
- transform: translateX(0px);
- }
- 100%{
- transform: translateX(-100px);
- }
- }
- style>
-
- <div class="box1">div>
- <div class="box2">div>
- <style>
- *{margin:0;padding:0}
- div{float:left}
- .box1{width:300px;height:300px;background-color:red}
- .box2{width:100px;height:100px;background-color:green}
- style>
-
- <div class="box1">div>
- <div class="box2">div>
-
- <script>
- //获取元素
- //设置x和y的值
- //绑定鼠标移入事件==缓慢移动 x的位置进行移动 自减
- 6、boder实现0.5像素
- 实现方法:CSS3有缩放的属性,我们可以利用这个属性,缩小50%的1px的边框,来实现这个功能代码如
- 下:
- 7、场景题(两个盒子,左边固定宽,右边自适
- 应,你能想到几种方法)
- 公共HTML代码部分
- 方法一:float来和BFC实现
- //绑定鼠标移出事件==缓慢移动 x的位置进行移动 自增
- script>
important > 内联 > ID > 类| 伪类 | 属性选择|伪对象 > 标签 > 继承 > 通配符