兔子缩放后定位不准

兔子缩放后定位不准

兔子缩放后定位不准,bottom:50px ,right:200px

没用

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

5回答
小丸子爱吃菜 2017-01-07 11:02:53

兔子本身的图片比较大,你虽然对它进行了缩放,但是缩放的只是该元素,并不是图片,图片只是该元素的背景图片。

解决办法:用img标签引入图片,对图片的宽高进行设置或者对img标签进行缩放,这样兔子就可以正常显示在页面中了。

祝学习愉快!

提问者 或許冭假 2017-01-06 21:57:56
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
* {
    margin0;
    padding0;
}
 
/*蓝天*/
body > div:first-of-type {
    positionrelative;
    /*overflow: hidden;*/
    width100vw;
    height50vh;
    background: linear-gradient(to bottomrgb(196228253), #ffffff);
}
 
/*蓝天*/
body > div:last-of-type {
    positionrelative;
    bottom0;
    width100vw;
    height50vh;
    background: linear-gradient(to bottom#ffffffrgb(14819089));
}
 
/*云的样式*/
body > div:first-of-type > div > div.cloud,
body > div:first-of-type > div > div.cloud:before,
body > div:first-of-type > div > div.cloud:after,
body > div:first-of-type > div > div.cloud > div {
    width0;
    height0;
    border2.5vw solid transparent;
    border-radius: 2.5vw;
    backgroundwhite;
}
 
body > div:first-of-type > div > div.cloud {
    positionrelative;
}
 
body > div:first-of-type > div > div.cloud:before {
    positionabsolute;
    displayblock;
    content'';
    top-2vw;
    left-5.5vw;
    transform: scale(.6);
}
 
body > div:first-of-type > div > div.cloud:after {
    positionabsolute;
    displayblock;
    content'';
    top-1.2vw;
    left-4.9vw;
    transform: scale(0.5);
}
 
body > div:first-of-type > div > div.cloud > div:first-of-type {
    positionabsolute;
    top-1.3vw;
    left-6.5vw;
    transform: scale(0.4);
}
 
body > div:first-of-type > div > div.cloud > div:last-of-type {
    positionabsolute;
    top-1.4vw;
    left: -.7vw;
    transform: scale(0.5);
}
 
/*设置云为绝对定位*/
body > div:first-of-type > div {
    positionabsolute;
    right-10vw;
}
 
/*云的摆放位置*/
body > div:first-of-type > div:nth-of-type(1) {
    top5vh;
    transform: scale(0.8);
}
 
body > div:first-of-type > div:nth-of-type(2) {
    top7vh;
    transform: scale(0.6);
}
 
body > div:first-of-type > div:nth-of-type(3) {
    top9vh;
    transform: scale(0.6);
}
 
body > div:first-of-type > div:nth-of-type(4) {
    top11vh;
    transform: scale(.4);
}
 
body > div:first-of-type > div:nth-of-type(5) {
    top13vh;
    transform: scale(.5);
}
 
/*云的动画通用设置*/
body > div:first-of-type > div {
    will-change: animation;
    animation: cloud_animation ease-in-out infinite;
}
 
body > div:first-of-type > div:nth-of-type(1) {
    animation-duration: 11s;
}
 
 
body > div:first-of-type > div:nth-of-type(2) {
    animation-duration: 6s;
    animation-delay: 2s;
}
 
 
body > div:first-of-type > div:nth-of-type(3) {
    animation-duration: 9s;
    animation-delay: 4s;
}
 
 
body > div:first-of-type > div:nth-of-type(4) {
    animation-duration: 8s;
    animation-delay: 1s;
}
 
body > div:first-of-type > div:nth-of-type(5) {
    animation-duration: 7s;
    animation-delay: 1.5s;
}
 
/*动画的关键帧*/
@keyframes cloud_animation {
    from {
        right-10vw;
    }
    to {
        right110vw;
    }
}
 
/*兔子*/
body > div:last-of-type > div.rabbit {
    positionabsolute;
    max-width100px;
    max-height100px;
    transform: scale(.1);
    bottom50px;
    right200px;
    transform-origin: left top;
    backgroundurl("../images/rabbit.png"no-repeat center;
}


提问者 或許冭假 2017-01-06 21:57:23
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>蓝天白云</title>
    <link rel="stylesheet" href="css/cloud.css"/>
</head>
<body>
<!--蓝天-->
<div>
    <div>
 <!--云-->
 <div class="cloud">
            <div></div>
            <div></div>
        </div>
    </div>
    <div>
 <!--云-->
 <div class="cloud">
            <div></div>
            <div></div>
        </div>
    </div>
 
    <div>
 <!--云-->
 <div class="cloud">
            <div></div>
            <div></div>
        </div>
    </div>
 
    <div>
 <!--云-->
 <div class="cloud">
            <div></div>
            <div></div>
        </div>
    </div>
    <div>
 <!--云-->
 <div class="cloud">
            <div></div>
            <div></div>
        </div>
    </div>
 
</div>
<!--绿地-->
<div>
 <!--兔子-->
 <div class="rabbit"></div>
</div>
</body>
</html>


小丸子爱吃菜 2017-01-06 21:21:08

兔子是针对草地定位的,有可能是草地的高度或宽度过高,这样,你还是把你的代码发给我,语言描述不会太详细!

小丸子爱吃菜 2017-01-06 09:37:03

能否将你的问题描述的再清楚些,或者你上传截图,让我明白问题所在!

祝学习愉快!

  • 提问者 或許冭假 #1
    兔子那张图片不是很大,用transform进行缩放在根据绿地的div进行绝对定位bottom:50px,right:200px,兔子就被顶出屏幕外了,有什么好办法解决呢?
    2017-01-06 21:08:58
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码