使用嵌套的 div,每个 div 都有一个背景图像,我想要并排显示图像
我正在尝试并排放置星星。 这是我的 html 和 css 代码
<body>
<div class="rate-stars">
<div class"star" id="s5"><pre> </pre>
<div class"star" id="s4"><pre> </pre>
<div class"star" id="s3"><pre> </pre>
<div class"star" id="s2"><pre> </pre>
<div class"star" id="s1"><pre> </pre>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
我的 CSS:
.star
{
background-image: url("star-off.png");
float: left;
border: 0px;
width: 20px;
height: 20px;
margin: 0px;
padding: 20px;
}
最佳答案
您的第一个问题是您在所有类作业中都缺少 =
:
<div class"star"
^ missing =
修复了这些问题后,这个 CSS 就可以做到:
.star
{
background-image: url("star-off.png");
background-repeat:no-repeat;
width: 20px;
height: 20px;
margin-left:25px;
}
关于html - 嵌套div,每个div都有图片,并排显示图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15134362/