关于ABOUT区域图文混排的疑问?

关于ABOUT区域图文混排的疑问?

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

关于这部分的实现,我的思路是一个大的div容器,里面写八个小的div,分别容纳图片和内容。大盒子宽度设置100%,给这8个div设置左浮动,并且将宽度设置为25%,但是尝试之后发现图片和文字描述并不能在同一列显示,请问是哪里出了问题?

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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
<div class="header">
    <div class="logo">
        <img src="image/logo.png">
    </div>
    <div class="nav">
        <ul>
            <li><a href="#">HOME</a></li>
            <li><a href="#">ABOUT</a></li>
            <li><a href="#">GALLERY</a></li>
            <li><a href="#">FACULTY</a></li>
            <li><a href="#">EVENTS</a></li>
            <li><a href="#">CONTACT</a></li>
        </ul>
    </div>
</div>
<div class="banner">
    <div class="banner-picture">
        <img src="image/banner3.jpg">
    </div>
    <!--遮罩层-->
    <div class="topLayer">
 
    </div>
    <!--banner图部分的输入框-->
    <div class="topLayer-top">
        <form class="form">
            <input type="text" name="" placeholder="your Name">
            <br>
            <input type="text" name="" placeholder="your Profile">
            <br>
            <input type="text" name="" placeholder="your Email">
            <textarea placeholder="Write your Comments Here"></textarea>
            <br>
            <button>FIND MESSAGE</button>
        </form>
    </div>
</div>
<div class="middle">
    <div class="m-top">
        <div class="m-top-title">ABOUT</div>
        <!--添加蓝色下划线-->
        <div class="m-top-underline"></div>
        <div class="m-top-description">
            Lorem Ipsum is simply dummy text of the printing and typeseeting<br>
            industry. Lorem Ipsum has been the industry's standard dummy<br>
            text ever since the 1500s.
        </div>
    </div>
    <div class="m-middle">
        <div class="m-middle-left">
            <div class="word">A WORD ABOUT US</div>
            <div class="left-picture">
                <div class="description">Praesent dignissim viverra est,sed<br>
                    bibendum ligula congue non. Sed ax nislet<br>
                    felis gravida commodo? Suspendisse<br>
                    diam amet.
                </div>
                <div class="explore">
                    <button>EXPLORE</button>
                </div>
            </div>
        </div>
        <div class="m-middle-middle">
            <img src="image/bb3.jpg">
        </div>
        <div class="m-middle-right">
            <div class="about-right-content1">
                <div class="about-right-content1-number">
                    70000
                </div>
                <!--绘制蓝色下划线-->
                <div class="about-right-content1-underline">
 
                </div>
                <div class="about-right-content1-word">
                    Students
                </div>
            </div>
            <div class="about-right-content2">
                <div class="about-right-content2-number">
                    600
                </div>
                <!--绘制蓝色下划线-->
                <div class="about-right-content2-underline">
 
                </div>
                <div class="about-right-content2-word">
                    Faculty
                </div>
            </div>
        </div>
    </div>
</div>
<!--清除浮动-->
<div class="clear"></div>
<!--about底部图文混排-->
<div class="about-bottom">
    <div class="content1-picture">
        <img src="image/b1.jpg">
    </div>
    <div class="content1-word">
        <div class="title">
            Conference Hall
        </div>
        <div class="paragraph1">
            Lorem Ipsum is simply dummy text of the<br>
            printing and typesetting industry
        </div>
        <div class="paragraph2">
            Lorem Ipsum has been the industry's standard dummy<br>
            text ever since the 1500s, when an unknown printer took<br>
            a gallery of type and scrambled it to make a type<br>
            specimen book.
        </div>
    </div>
</div>
</body>
</html>

以下是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
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
* {
    margin0;
    padding0;
}
 
.header {
    width100%;
    height100px;
    background#07CBC9;
    /*固定顶部页面*/
    positionfixed;
    /*将头部页面置于顶层*/
    z-index10;
}
 
.header .logo {
    floatleft;
    padding-top26px;
}
 
.header .nav {
    floatright;
}
 
.header .nav ul {
    padding-right100px;
}
 
.header .nav ul li {
    display: inline-block;
    list-stylenone;
    margin0 30px;
    line-height100px;
}
 
.header .nav ul li a {
    text-decorationnone;
    colorwhite;
}
 
.header .nav ul li a:hover {
    color: gold;
    /*鼠标经过时产生加粗效果*/
    font-weightbolder;
}
 
.banner {
    /*给顶部导航栏预留100px*/
    padding-top100px;
    width100%;
    height1000px;
}
 
.banner .banner-picture img {
    displayblock;
    top100px;
    width100%;
    height1000px;
}
 
.banner .topLayer {
    width100%;
    height1000px;
    positionabsolute;
    top100px;
    left0;
    backgroundblack;
    opacity: 0.5;
}
 
.banner .topLayer-top {
    padding-top100px;
    positionabsolute;
    top100px;
    width800px;
    height800px;
    z-index2;
    margin50px 50%;
    left-400px;
    background-colortransparent;
}
 
.banner form {
    text-aligncenter;
}
 
.banner .form input {
    margin10px;
    width500px;
    height40px;
    colorwhite;
    /*设定输入字体大小*/
    font-size20px;
    background-colortransparent;
    border1px solid white;
}
 
.banner .form input:hover,
.banner .form textarea:hover {
    border3px solid #07cbc9;
}
 
.banner .form input::placeholder {
    colorwhite;
    font-size20px;
}
 
.banner .form textarea::placeholder {
    colorwhite;
    font-size20px;
    font-family: 微软雅黑;
}
 
.banner .form textarea {
    margin10px;
    width500px;
    height100px;
    background-colortransparent;
    border1px solid white;
    /*设定输入字体大小*/
    font-size20px;
}
 
.banner .form button {
    margin10px;
    width150px;
    height50px;
    background-colortransparent;
    colorwhite;
    border1px solid #F2FFF3;
}
 
/* 鼠标滑过提交按钮时,按钮没有边框,背景颜色变成#07cbc9。*/
.banner .form button:hover {
    bordernone;
    background-color#07cbc9;
}
 
/*设置标题样式*/
.middle .m-top .m-top-title {
    text-aligncenter;
    font-size40px;
    font-weightbold;
    padding-top50px;
    padding-bottom10px;
}
 
/*为ABOUT下方添加蓝色下划线*/
.middle .m-top .m-top-underline {
    top20px;
    margin0 auto;
    width30px;
    height2px;
    background-color#07CBC9;
}
 
/*为描述文字设置样式*/
.middle .m-top .m-top-description {
    line-height25px;
    padding-top30px;
    text-aligncenter;
    colorgray;
}
 
/*为中间ABOUT部分主体设置居中样式*/
.middle {
    margin0 auto;
    width1308px;
}
 
.middle .m-middle .m-middle-left {
    width370px;
    floatleft;
}
 
/*设置左侧标题文字样式*/
.middle .m-middle .m-middle-left .word {
    padding-top10px;
    padding-left150px;
    text-aligncenter;
    width200px;
    font-size30px;
}
 
/*设置左侧描述文字样式*/
.middle .m-middle .m-middle-left .left-picture {
    /*给左侧描述文字设置左浮动*/
    floatleft;
    margin-left150px;
    width370px;
    height246px;
    /*为左侧描述文字设置背景颜色和透明度*/
    background: rgba(2552552550.5);
    positionrelative;
    border1px solid gray;
}
 
.middle .m-middle .m-middle-left .left-picture .description {
    colorblack;
    padding-left15px;
    padding-top15px;
}
 
/*设置explore按钮的样式*/
.middle .m-middle .m-middle-left .left-picture .explore {
    padding-left15px;
    padding-top10px;
}
 
/*设置explore按钮的样式*/
.middle .m-middle .m-middle-left .left-picture button {
    width102px;
    height45px;
    background-colorblack;
    border1px solid black;
    colorwhite;
}
 
/* 中间部分左侧的EXPLORE按钮,鼠标移入时背景变为透明的,但是有黑色的边框*/
.middle .m-middle .m-middle-left .left-picture button:hover {
    background-colortransparent;
    colorblack;
}
 
/*设置中间图片的样式*/
.middle .m-middle .m-middle-middle img {
    padding-top15px;
    floatleft;
    displayblock;
    width568px;
    height380px;
}
 
/*设置图片右侧文字样式*/
.middle .m-middle .m-middle-right {
    padding-top15px;
    floatleft;
    width370px;
    height400px;
}
 
/*设置ABOUT部分右上角样式*/
.middle .m-middle-right .about-right-content1 {
    text-aligncenter;
    margin-left30px;
    width238px;
    height144px;
    border1px solid #07CBC9;
    font-weightbolder;
}
 
/*设置ABOUT右上角数字的样式*/
.middle .m-middle-right .about-right-content1 .about-right-content1-number {
    font-size30px;
    padding-top10px;
    padding-bottom15px;
}
 
.middle .m-middle-right .about-right-content1 .about-right-content1-word{
    font-size20px;
    padding-top15px;
}
 
.middle .m-middle-right .about-right-content1 .about-right-content1-underline,.about-right-content2-underline{
    margin0 auto;
    width40px;
    height2px;
    background-color#07CBC9;
}
 
/*设置ABOUT部分右下角样式*/
.middle .m-middle-right .about-right-content2 {
    margin-top30px;
    text-aligncenter;
    margin-left30px;
    width238px;
    height144px;
    border1px solid #07CBC9;
    font-weightbolder;
}
 
.middle .m-middle-right .about-right-content2 .about-right-content2-number{
    font-size30px;
    padding-top10px;
    padding-bottom15px;
}
 
.middle .m-middle-right .about-right-content2 .about-right-content2-word{
    font-size20px;
    padding-top15px;
}
.about-bottom{
    width100%;
}
.clear{
    clearboth;
}
 
.about-bottom{
    width100%;
}
 
.about-bottom .content1-picture{
    width25%;
    floatleft;
}
.content1-word{
    width25%;
    background-color#07CBC9;
    floatleft;
}


正在回答

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

2回答

同学你好,同学描述错误了,设置浮动之后,应该是同一行显示,不叫同一列。另外,同学回复区域给出的链接是本题的链接,没有办法看你另一个问题,不过没有关系,同学已经提问的问题,答疑老师都会解决的。老师这边测试同学的代码,盒子是在同一行显示的。只不过图片的父容器宽度是设置的百分比,会随着分辨率的缩放而缩放。但是图片默认显示原图大小,所以分辨率大的时候,图片不能铺满父容器,分辨率小的时候,图片又会超出父容器。

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

这里的解决方式就是给图片设置宽度100%,让它一直相当父容器100%显示。如下:

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

另外,这一块的代码和样式可以优化一下,参考如下:

通过about-bottom>div选中about-bottom下面的8个子元素,共同设置相同的样式

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

如果我的回答帮到了你,欢迎采纳,祝学习愉快~

提问者 weixin_慕设计1308382 2020-07-18 10:11:56

我刚才发现这个实现不够好,尝试了另一种方法,但依然存在问题。问题链接:https://class.imooc.com/course/qadetail/241189

问题已解决,确定采纳
还有疑问,暂不采纳

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

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

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

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

帮助反馈 APP下载

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

公众号

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

在线咨询

领取优惠

免费试听

领取大纲

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