<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> /* #box ul { width: 500px; height: 100px; list-style: none; border: 1px solid gray; padding: 0; } #box ul img{ float: left; width: 82px; height: 82px; border: 1px solid gray; padding: 2px; margin: 6px } */ /* 参考答案 */ ul {list-style: none; padding: 0;} ul { width: 500px; height: 100px; border: 1px solid gray; } ul li { float: left; width: 70px; height: 70px; border: 1px solid gray; padding: 5px; margin: 9px; } ul li img { width: 100%; height: 100%; } </style> </head> <body> <div id="box"> <ul> <li><img src="a.png" /></li> <li><img src="a.png" /></li> <li><img src="a.png" /></li> <li><img src="a.png" /></li> <li><img src="a.png" /></li> </ul> </div> </body> </html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/*
#box ul {
width: 500px;
height: 100px;
list-style: none;
border: 1px solid gray;
padding: 0;
}
#box ul img{
float: left;
width: 82px;
height: 82px;
border: 1px solid gray;
padding: 2px;
margin: 6px
}
*/
/* 参考答案 */
ul {list-style: none; padding: 0;}
ul {
width: 500px;
height: 100px;
border: 1px solid gray;
}
ul li {
float: left;
width: 70px;
height: 70px;
border: 1px solid gray;
padding: 5px;
margin: 9px;
}
ul li img {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="box">
<ul>
<li><img src="a.png" /></li>
<li><img src="a.png" /></li>
<li><img src="a.png" /></li>
<li><img src="a.png" /></li>
<li><img src="a.png" /></li>
</ul>
</div>
</body>
</html>
标签:width,练习,height,padding,ul,1px,HTML,border,CSS
From: https://blog.csdn.net/m0_61566562/article/details/140072332