1、图片和文字在同一行
<img src="image/icon-youxiang.png" alt="" class="dis_ver">
<div class="dis_ver">hello world</div>
观察到,img和div的class是相同的,都是“dis_ver”,则通过 display: inline-block 定义
.dis_ver{
display: inline-block;
}
2、 ul无序列表布局联系人信息
<html>
<head>
<style>
body{
margin:0px;
}
/* .box1{
border:1px solid black;
width: 47%;
box-sizing: border-box;
padding: 30px;
height: 200px;
float: left;
margin-left: 2%;
margin-bottom: 5%;
}
.text1
{
display: flex;
align-items: center;
justify-content: space-between;
}
.left
{
width: 70%;
line-height: 50px;
background-color: red;
text-align: center;
font-size: 28px;
}
.right
{
width: 30%;
line-height: 50px;
background-color: yellow;
text-align: center;
font-size: 8px;
} */
.dis_ver{
display: inline-block; /* img和div,class都叫“dis_ver”,将图片与后面的文字放在一行内,否则图片在上,文字另起一行 */
}
.personalInfoList img{
width:15px;
}
ul,li{
border: 1px solid black;
list-style-type: none; /* 去除默认的小黑点 */
}
.personalInfoList{
display: flex; /* 定义ul为灵活盒子。此时内部li排列都是横向 */
flex-wrap: wrap; /* 允许换行:内部li横向排列超出ul宽度时,自动换行 */
width: 70%;
padding-left: 0;
}
.personalInfoList li{
width: 45%; /*45%+45%=90%<100%,两个li不换行,三个则换行*/
margin-bottom: 4px;
}
.personalInfoList li:last-child{ /*对最后一个li重新定义宽度*/
width: 100%;
}
</style>
</head>
<body>
<!-- <div class="box1">
<div class="text1">
<div style="border: 1px solid black; font-size:50px;">
hello!
</div>
<div style="border: 1px solid black; ">
world!
</div>
</div>
</div>
<div class="box1">
<div class="text1">
<div class="left">
hello!
</div>
<div class="right">
world!
</div>
</div>
</div>
<div class="box1">
</div>
<div class="box1">
</div> -->
<ul class="personalInfoList">
<li>
<img src="image/icon-dianhua.png" alt="" class="dis_ver">
<div class="dis_ver">130000000</div>
</li>
<li>
<img src="image/icon-youxiang.png" alt="" class="dis_ver">
<div class="dis_ver">www.baidu.com</div>
</li>
<li>
<img src="image/icon-zuoji.png" alt="" class="dis_ver">
<div class="dis_ver">(0531)5800000</div>
</li>
<li>
<img src="image/icon-youbian.png" alt="" class="dis_ver">
<div class="dis_ver">250000</div>
</li>
<li>
<img src="image/icon-dingwei.png" alt="" class="dis_ver">
<div class="dis_ver">山东济南泉城广场</div>
</li>
</ul>
</body>
</html>