老师,我写到一半发现,为什么我的窗口缩放,所有元素的位置都变化了,怎么解?

老师,我写到一半发现,为什么我的窗口缩放,所有元素的位置都变化了,怎么解?

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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Career Builder</title>
    <style type="text/css">
    *{padding:0;margin:0;font-family: "Microsoft YaHei UI";}
    .header{
        width:100%;
        height:100px;
        background: #07cbc9;
    }
    .logo{
        float: left;
        margin-top: 20px;
        padding-left: 80px;   
    
    .nav{
        float: right;
    }
    .nav li{
        float:left;
        margin-right: 50px;
        list-style:none;
        color: white;
        font-weight: bold;
        font-size: 18px;
        height:100px;
        width: 80px;
        line-height: 100px;
    }
    .banner-pic img{
        width: 100%;
        height: 700px;
    }
    .top-layer{
        width:100%;
        height:700px;
        position:absolute;
        top: 100px;
 
 
    }
    form{
        width: 500px;
        height:320px;
        position: relative;
        top:50%;
        margin-top:-160px;
        left:50%;
        margin-left:-250px;
    }
    input{
         
        border: 1px solid #fff;
        width: 450px;
        height:35px;
        margin-top:20px;
        background: none;
    }
    .submit{
        width:200px;
        color:#fff;
        margin-left:125px;
    }
    .comment{
        height:80px;
    }
    input::-webkit-input-placeholder{
        color:#fff;
    }
   input::-moz-placeholder{
        color:#fff;
    }
    input:-moz-placeholder{
        color:#fff;
    }
    input:-ms-input-placeholder{
        color:#fff;
    }
    .about{
        width:100%;
 
    }
    .about-1{
        text-align: center;
    }
   .about-1 h1{
     font-weight: bold;
     margin-top:30px;
   }
   .about-1 p{
     color:gray;
     line-height: 30px;
   }
   .bluebar{
     width:25px;
     height: 2px;
     background:#07cbc9;
    margin:10px auto;
   }
   .about-2{
     width:100%;
     height: 450px;
     margin-top:40px;
     position: relative;
   }
   .about-2-1,.about-2-2,.about-2-3{
     float: left;
   }
   .about-2-1{
     width:400px;
     height:400px;
     position: absolute;
     left: 400px;
     z-index: 2;
   }
   .about-2-1 h1{
     text-align: center;
     width: 250px;
 
   }
   .about-2-1 .word{
     border:  1px solid grey;
     width: 400px;
     height: 250px;
     background: #fff;
     opacity: 0.3;
    }
    .word-toplayer{
        width: 320px;
        height:320px;
        background: none;
        position: relative;
        top:-200px;
        left:20px;
        line-height: 20px;
 
   }
    .button{
     background:black;
     width:90px;
     height: 40px;
     color:#fff; 
     padding: 10px;
     box-sizing:border-box; 
     margin-top:20px;
   }
   .about-2-2 img{
     width:600px;
     height: 450px;
   }
   .about-2-2{
     position: absolute;
     left: 50%;
     margin-left: -300px;
   }
   .about-2-3{
     position: absolute;
     left:1280px;
      
   }
   .about-2-3-1{
     width:200px;
     height: 150px;
    border: 2px solid #07cbc9;
    box-sizing: border-box;
    padding: 20px;
   }
   .about-2-3-1 h1{
     text-align: center;
   }
   .about-2-3-1 hr{
     width: 40px;
     height: 1px;
     background:#07cbc9;
     margin:20px auto;
   }
   .about-2-3-1 p{
     text-align: center;
     font-size: 20px;
   }
 
 .about-2-3-2{
     width:200px;
     height: 150px;
    border: 2px solid #07cbc9;
    box-sizing: border-box;
    padding: 20px;
    margin-top: 30px;
   }
   .about-2-3-2 h1{
     text-align: center;
   }
   .about-2-3-2 hr{
     width: 40px;
     height: 1px;
     background:#07cbc9;
     margin:20px auto;
   }
   .about-2-3-2 p{
     text-align: center;
     font-size: 20px;
   }
   .about-3{
     width: 100%;
   }
   .about-3-top{
     width: 100%;
   }
   .about-3-top-1,.about-3-top-2{
     float: left;
      
   }
   .about-3-top-1 {
     width: 25%;
      
   }
   .about-3-top-1 img{
     width:100%;
     height: 400px;
   }
   .about-3-top-2{
     width:25%;
     height:400px;
     background: #07cbc9;
     position: relative;
     z-index: 3;
     color:#fff;
 
 
   }
   .triangle {
    width: 0;
    height: 0;
    border-top: 20px solid transparent;
    border-right: 40px solid #07cbc9;
    border-bottom: 20px solid transparent;
    position: absolute;
    left: -40px;
    top:180px;
}
 
.w-1{
    font-size: 26px;
    margin: 20px;
}
.w-2{
    font-size: 18px;
    margin-left: 20px;
    line-height: 30px;
}
.w-3{
    font-size:15px;
    margin: 20px;
    line-height: 30px;
}
.button-2{
    background:black;
     width:90px;
     height:40px;
     color:#fff; 
     padding: 10px;
     box-sizing:border-box;
    position: absolute;
    left:50%;
    margin-left: -45px;
    top:75%;
 
     
}
    </style>
}
}
}
}
}
}
</head>
<body>
    <div class="header">
        <div class="logo">
            <img src="images/logo.png"/>
        </div>
        <div class="nav">
            <ul>
            <li>HOME</li>
            <li>ABOUT</li>
            <li>GALLERY</li>
            <li>FACULTY</li>
            <li>EVENTS</li>
            <li>CONTACT</li>
        </ul>
        </div>
    </div>
    <div class="banner">
        <div class="banner-pic">
            <img src="images/banner3.jpg"/>
        </div>
        <div class="top-layer">
            <form action="#" method="post">
                <div>
                    <input type="text" name="user" placeholder="  your Name"/>
                </div>
                <div>
                    <input type="text" name="phonenumber" placeholder="  your phone"/>
                </div>
                <div>
                    <input type="text" name="email" placeholder="  your Email"/>
                </div>
                <div>
                    <input type="text" name="email" placeholder="  Write Your Comment Here" class="comment" />
                </div>
                <div>
                <input type="submit" name="submit" value="SEND MESSAGE" class="submit" />  
                </div>
            </form>  
        </div>
    </div>
    <div class="about">
        <div class="about-1">
            <h1>ABOUT</h1>
            <div class="bluebar"></div>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting <br/>industry.Lorem Ipsum has been the industry's standard dummy<br/> text ever since the 1500s.</p>
        </div>
        <div class="about-2">
            <div class="about-2-1">
                <h1>A WORD ABOUT US</h1>
                <div class="word"></div>
                    <div class="word-toplayer">
                        Praesent dignissim viverra est,sed<br>bibendum ligula congue non.sed ac nis<br>et felis gravida commodo?suspendisse<br>eget ullamcorper ipsum.suspendisse<br>diam amet
                    <div class="button">EXPLORE</div
                </div>
            </div>
            <div class="about-2-2">
                <img src="images/bb3.jpg"/>
            </div>
            <div class="about-2-3">
                <div class="about-2-3-1">
                    <h1>70000</h1>
                    <hr>
                    <p>Students</p>
                </div>
                <div class="about-2-3-2">
                    <h1>600</h1>
                    <hr>
                    <p>Faculty</p>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="about-3">
            <div about-3-top>
            <div class="about-3-top-1">
                <img src="images/b1.jpg">
            </div>   
            <div class="about-3-top-2">
                <p class="w-1">Library</p>
                <p class="w-2">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>
                <p class="w-3">Lorem Ipsum has been the industry'standard dummy text ever since the 1500s,when an unknow printer took agalley of type and scrambled it to make a type specimen book.</p>
                <div class="triangle"></div>
                <div class="button-2">EXPLORE</div>
 
                 
            </div>   
            <div></div>
            <div></div>
            </div>
            <div about-3-bottom></div>
        </div>
    </div>
    <div>
         
    </div>
    <div class="footer"></div>
</body>
</html>


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

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

2回答
好帮手慕糖 2018-07-30 16:07:15

你好,因为你“ABOUT”区域中间部分,使用的定位设置的,例如右侧的文字块都是使用left移过去的,但是窗口缩小,窗口的宽度,可能还没有你设置的left值大,所以建议:可以按照上个回答的建议修改下布局,然后在设置最小宽度,可以给body设置,也可以给每个区域都设置下哦。

样式这里,不知道是有东西没写还是怎么样?可以检查下,多了几个“}”

http://img1.sycdn.imooc.com//climg/5b5ec70d0001560102440060.jpg

祝学习愉快~

好帮手慕糖 2018-07-30 11:50:05

你好,可以给设置下最小宽度。另,建议:

about区域中间部分。建议:这部分可使用一个盒子包裹,然后给盒子设置具体的宽度,然后设置margin:0 auto;来实现整体居中,内部可以安照从左到右布局,首先是左侧小标题,其次是中间的图片,然后为右侧的两个小区域。左侧的文字区域因一部分在图片上。可用定位来实现。

若能解决你的疑问,望采纳。

祝学习愉快~

  • 提问者 aleeeeex #1
    设置最小宽度是给谁设置最小宽度?我给body 还有about-2 还有banner设置了最小宽度1000px,都不行。
    2018-07-30 15:57:53
问题已解决,确定采纳
还有疑问,暂不采纳

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

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

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

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

帮助反馈 APP下载

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

公众号

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

在线咨询

领取优惠

免费试听

领取大纲

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