<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body,p{
margin: 0;
padding: 0;
}
div{
width: 300px;
height: 200px;
background: yellow;
text-align: center;
/* 这里是为了让p这个容器居中,容器居中了,内容跟着 一起了 */
}
p{
background: blue;
text-align: left;
/* 这里的是为了让文字靠左对齐 */
display: inline-block;
}
</style>
</head>
<body>
<div>
<p>文字内容文字内容文字内容文字内容文字内容文字内容</p>
</div>
</body>
</html>
内容不同的时候,效果不同
最新推荐文章于 2022-03-13 13:49:09 发布