gpt4 book ai didi

html - 如何从 html 中分离图像,以便我可以编辑它在网站上的位置?

转载 作者:太空宇宙 更新时间:2023-11-04 12:12:22 24 4
gpt4 key购买 nike

我是 html 的新手,我不知道如何隔离图像以使其不受 CSS img 代码的影响。我尝试使用

<a href="hello.png"><img src="images/hello.png" height="100" width="350"/></a>
<a href="hello.png"><"div id=img2" src="images/hello.png" height="100" width="350"/></a>

(我创建了一个名为 #img2 的 css)之类的东西,但由于某种原因它并没有真正起作用。

最佳答案

我假设你有

<a href="hello.png"><img src="images/hello.png" height="100" width="350"/></a>

并希望使用 CSS 控制它的样式,确保它不会被引用的 css 文件/ block 中的 img 样式设置样式

  1. 给img标签添加一个id

    ... img id="myimage"src="images/hello.png"height="100"width="350"/> /a>

  2. 创建一个样式来定位您的 ID:

    img#我的图片{ /在此处放置样式以覆盖 img 样式/

对于 css,更具体的匹配将覆盖不太具体的匹配(即 img#myimage 胜过图像),但 !important 将胜过更好的匹配。如果你的 img 样式有 !important 你需要将它添加到你的 img#myimage 样式中

关于html - 如何从 html 中分离图像,以便我可以编辑它在网站上的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28953919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com