老师,麻烦看看有没有问题

来源:2-7 编程练习

慕前端2185815

2020-08-07 21:47:09

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

<title>CSS布局</title>

<style type="text/css">

/*此处写代码*/

.header{

width:100%;

margin:0 auto;

/*background:gray;*/

text-align:center;

padding-bottom:10px;

padding-top:30px;

font-size:30px;

font-weight:bold;

}

.content{

width:100%;

}

.content .con{

width:48%;

float:left;

text-align:center;

margin:10px 10px 10px 0;


}

.content .con img{

width:493px;

height:250px;

}

.content .con .des{

font-size:20px;

padding-top:5px;

}

</style>


</head>

<body>

<!-- 此处写代码 -->

<div class="header">

ENJOY THE LIFE

</div>

<div class="content">

<div class="con">

<img src="http://climg.mukewang.com/58f829090001a4b504260240.jpg">

<div class="des">

Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book</div>

</div>

<div class="con">

<img src="http://climg.mukewang.com/58f8290f0001558804260240.jpg">

<div class="des">

Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book</div>

</div>

</div>

</body>

</html>


写回答

3回答

好帮手慕星星

2020-08-08

同学你好,测试代码时老师加了一个背景色,可以看到右侧还有间隙

http://img.mukewang.com/climg/5f2e01d7092960dd19200419.jpg

建议右侧的设置右浮动,并且去掉右边距。下面的文字是左对齐显示的,不需要设置居中。参考修改

http://img.mukewang.com/climg/5f2e02be09ee434304580430.jpg

http://img.mukewang.com/climg/5f2e02af09040aa204180269.jpg

优化:为了美观一些,建议将content盒子设置为固定宽度,然后居中

http://img.mukewang.com/climg/5f2e030a097e5d2c03310133.jpg

祝学习愉快!

0

慕前端2185815

提问者

2020-08-07

看下面回复里面的代码有无问题就可以

0

慕前端2185815

提问者

2020-08-07

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

<title>CSS布局</title>

<style type="text/css">

/*此处写代码*/

.header{

width:100%;

margin:0 auto;

/*background:gray;*/

text-align:center;

padding-bottom:10px;

padding-top:30px;

font-size:30px;

font-weight:bold;

}

.content{

width:100%;

}

.content .con{

width:48%;

float:left;

text-align:center;

margin:10px 10px 10px 0;


}

.content .con img{

width:100%;

height:250px;

}

.content .con .des{

font-size:20px;

padding-top:5px;

}

</style>


</head>

<body>

<!-- 此处写代码 -->

<div class="header">

ENJOY THE LIFE

</div>

<div class="content">

<div class="con">

<img src="http://climg.mukewang.com/58f829090001a4b504260240.jpg">

<div class="des">

Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book</div>

</div>

<div class="con">

<img src="http://climg.mukewang.com/58f8290f0001558804260240.jpg">

<div class="des">

Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book Life is like a book</div>

</div>

</div>

</body>

</html>


0

0 学习 · 40143 问题

查看课程