居中且带有盒子阴影
<!DOCTYPE html>
<html>
<head>
<title>居中盒子示例</title>
<style>
.container {
width: 300px;
height: 200px;
margin: 0 auto; /* 使用 margin 属性实现水平居中 */
display: flex;
align-items: center; /* 使用 align-items 属性实现垂直居中 */
justify-content: center; /* 使用 justify-content 属性实现垂直居中 */
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); /* 添加盒子阴影效果 */
}
.content {
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<h1>居中盒子</h1>
<p>这是一个居中且带有盒子阴影的示例</p>
</div>
</div>
</body>
</html>
推荐阅读:
扫描二维码,在手机上阅读