【发布时间】:2022-11-26 17:08:41
【问题描述】:
我正在寻找如何通过为 CSS 上的多个 div 类提供相同的宽度、高度和边距来将单一样式应用到它们
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page title</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="landing page">
<div class="box 1"></div>
<div class="box 2"></div>
<div class="box 3"></div>
<div class="box 4"></div>
<div class="box"></div>
<div class="box">/div>
</div>
</body>
</html>
CSS
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.landing page{
width: 100%;
height: 100vh;
}
.box 1, box 2, box 3{
width: 30%;
height: 15vh;
margin: 2px;
}
但我还想通过添加 2px 黄色边框向 CSS 中的两个 div 类添加样式,以便它们从 d rest 中脱颖而出。例如
CSS
.box1 .boxes{
border: 2px yellow solid;
}
【问题讨论】:
-
我没看懂你的第二个问题