老师,检查一下,怎么让文字段落的长度和图片一样

来源:2-7 编程练习

慕九州8176055

2019-09-28 20:54:51

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

<title>CSS布局</title>

<style type="text/css">

/*此处写代码*/

*{margin:0 auto;padding: 0;}

.main{width: 1000px;overflow: hidden;}

h2{margin:10px 0;text-align: center;}

.dec{float: left;margin: 10px;}

img{width: 480px;height: 320px;}

.desc{}


</style>

</head>

<body>

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

<div class="main">

<h2>ENJOY THE LIFE</h2>

<div class="dec">

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

<div class="desc"> Life si like a book,just read more and more<br> 

refined,more write more carefully. When read,<br>mind open,all 

things have been indifferent to<br> heart.Life is the precipitation.

</div>

</div>

<div class="dec">

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

<div class="desc"> Life is like a cup of tea,let people lead a<br>

person to endless aftertastes.You again good<br>

taste.it will always have a different taste<br>

more</div>

</div>



</div>

</body>

</html>


写回答

1回答

好帮手慕言

2019-09-29

同学你好,如果要实现文字段落的长度和图片一样,那么建议:去掉br标签,给类名为desc的元素设置宽度,并且值和图片的宽度值一致。

代码参考:
http://img.mukewang.com/climg/5d900ed609e475bd11490738.jpg


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

其他地方实现的是可以的,继续加油,祝学习愉快~

0

0 学习 · 40143 问题

查看课程