如何使用内嵌css在html中定位图像?

如何使用内嵌css在html中定位图像?,html,django-inlinecss,Html,Django Inlinecss,我试图将图像定位到某个特定的位置,因此我需要使用“顶部”、“左侧”参数,而不仅仅是“对齐:中心”。我使用了下面的代码,但它无法将图像移动到屏幕上的任何位置,它在某个位置保持不变 <img src="./assets/button.png" alt="button" position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;> 请帮忙解决这个问题。提前谢

我试图将图像定位到某个特定的位置,因此我需要使用“顶部”、“左侧”参数,而不仅仅是“对齐:中心”。我使用了下面的代码,但它无法将图像移动到屏幕上的任何位置,它在某个位置保持不变

<img src="./assets/button.png" alt="button" position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;>

请帮忙解决这个问题。提前谢谢

使用类似的方法。 将所有css属性放入样式中

<img 
    src="./assets/button.png"
    alt="button"
    style="position:absolute; width:346px; height:40px; left:1041px; top:546px;"
>

使用类似的方法。 将所有css属性放入样式中

<img 
    src="./assets/button.png"
    alt="button"
    style="position:absolute; width:346px; height:40px; left:1041px; top:546px;"
>

像这样使用

<img src="./assets/button.png" alt="button" style="position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;">
<div style="position: relative;">
// other codes here
</div>

同样,当你将它定位到一个特定的位置时,你必须确定它是相对于哪个位置的

假设您希望它相对于一个div。使该div的样式如下

<img src="./assets/button.png" alt="button" style="position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;">
<div style="position: relative;">
// other codes here
</div>

//这里还有其他代码
像这样使用

<img src="./assets/button.png" alt="button" style="position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;">
<div style="position: relative;">
// other codes here
</div>

同样,当你将它定位到一个特定的位置时,你必须确定它是相对于哪个位置的

假设您希望它相对于一个div。使该div的样式如下

<img src="./assets/button.png" alt="button" style="position: absolute; width: 346px; height: 40px; left: 1041px; top: 546px;">
<div style="position: relative;">
// other codes here
</div>

//这里还有其他代码

问题在于缺少“style”属性,否则代码应该正常运行。

问题在于缺少“style”属性,否则代码应该正常运行。

通过使用相对位置,我可以在某个位置修复图像,比如在页面底部,即使页面中没有其他内容,默认情况下,任何内容都会自动与正文相关。因此,如果没有ang,则将元素设为绝对元素,并给出底部:0。然后它会定位到底部哦,太好了。我现在拿到了,谢谢你的帮助!通过使用相对位置,我可以将图像固定在某个位置,比如页面底部,即使页面中没有其他内容?默认情况下,所有内容都自动相对于主体。因此,如果没有ang,则将元素设为绝对元素,并给出底部:0。然后它会定位到底部哦,太好了。我现在拿到了,谢谢你的帮助!