2021/3/17 练习布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>聊天对话框</title>
<style type="text/css">
* {
padding: 0;
margin: 0;
}
ul {
list-style: none;
/*将无序列表的默认样式去掉*/
width: 300px;
height: 400px;
margin: auto;
/*对话框居中*/
border: 1px dotted black;
/*合并写法*/
}
.all{
clear: both;
}
.left{
float: left;
margin-left: 6px;
background: whitesmoke;
}
.right{
color: white;
float: right;
margin-right: 6px;
background: green;
}
</style>
</head>
<body>
<ul>
<li class="all left">天王盖地虎!</li>
<li class="all right">宝塔镇河妖!</li>
<li class="all left">脸红什么?</li>
<li class="all right">精神焕发</li>
<li class="all left">咋的又黄了?</li>
<li class="all right">嘿嘿,防冷涂的蜡</li>
</ul>
</body>
</html>
效果图