这是我正在做的事情,
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>David Paint</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { background: linear-gradient(to right, #00e5ff, #00e676); margin: auto; max-width: 736px; font-size: 0px }
#icons img { width: 36px }
</style>
</head>
<body>
<span id="icons">
<a href="david">
<img title="David" src="david.svg">
</a>
<a href="paint">
<img title="Paint" src="paint.svg">
</a>
</span>
</body>
</html>
如何使用 CSS 选择器 来定位 <img title="Paint" src="paint.svg">
不添加更多的类或 ID?当我包装 img
时出现问题a
中的标签标签。在此之前,我可以定位最后一个 img
标签没问题。
谢谢!
最佳答案
您可以使用以下每种方式
#icons img[title = 'paint'] { ... }
#icons img[src = 'paint.svg']{ ... }
#icons a:last-child img { ... }
#icons a:nth-child(2) img { ... }
关于html - 邻居的 CSS 选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38451503/