用dl dt dd后 用float 为什么没变化?

来源:2-7 编程练习

大白前端

2020-02-02 14:35:39

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

<title>CSS布局</title>

<style type="text/css">

/*此处写代码*/

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

.continer{text-align:center;}

img{width:230px;}

.t1{float:left;}

.t2{float:left;}

</style>

</head>

<body>

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

<div class="continer">

    <h>ENJOY THE LIFE</h>

     <div class="t1">

        <dl>

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

            <dd>life is like a book,just read more and more refined,more write more carefullt,when read,mind open,all things have been indifferent to heart.life is the precipitations.</dd>

        </dl>

    </div>

    <div class="t2">

        <dl>

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

            <dd>life is like a cup of tea.let people lead a person to afternoons.you are good taste.it will always have a different taste,different people will have different taste.</dd>

        </dl>

        

    </div>

</div>


</body>

</html> 


写回答

2回答

好帮手慕码

2020-02-03

同学你好,代码中只设置了t1,t2浮动,并没有设置它下面的dl,dt,dd浮动:

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

建议修改如下:

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

这样三者都有浮动的样式了。

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

0

qq_慕妹2226526

2020-02-03

    <style type="text/css">

        /*此处写代码*/

        

        * {

            margin: 0px;

            padding: 0px;

        }

        

        .continer {

            text-align: center;

        }

        

        img {

            width: 230px;

        }

        

        .t1 dl dt,

        .t1 dl dd {

            float: left;

        }

        

        .t2 dl dt,

        .t1 dl dd {

            float: left;

        }

    </style>

替换你原有的CSS样式,看跟你的区别

0

0 学习 · 40143 问题

查看课程