我正在尝试为网站定位一些图像,并且我给了这些图像不同的 ID,因此我可以以不同的方式定位它们。在我的CSS上,当我开始定位时它不起作用。通过 ID 或类别,
我将这些图像放置在 div 中只是为了检查一切是否正常,并且我想可以轻松指向我想要使用的确切 img 标签。
代码如下:
<--html-->
<div class="resume">
<a href="#"><img style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/pdf.png" class="pdf" ></a>
<a href="#"><img id="word" style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/mword.png" ></a>
<img id="pline" style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/line1.png" >
<img id="wline" style="height:auto; width:auto; max-width:100px; max-height:100px;"src="imgs/line2.png" >
</div>
Run Code Online (Sandbox Code Playgroud)
<--css-->
.resume img
{
position:relative;
top:100px;
}
.resume img .pdf
{
position: relative;
top:500px;
}
Run Code Online (Sandbox Code Playgroud)
因此,如果有人能帮助我解决我出错的地方,我将不胜感激。谢谢!
img和之间不应有空格.pdf。这意味着 img 标签包含带有 class 的一个或多个元素.pdf。img.pdf表示具有此类的 img 标签。
对于您只需使用 id #pline,则无需使用,img#pline因为 id 在页面上是唯一的,并且img #pline如上所述是不正确的。