Search code examples
htmldjango-inlinecss

How to position the image in html with inline css?


I am trying to position an image somewhere in particular, so I need to use "top", "left" parameters instead of just "align: center". I used the below code, but it fails to move the image anywhere on the screen, it remains constant at a place.

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

Kindly help solve this. Thanks in advance!


Solution

  • Use like this

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

    Also as you are positioning it to a specific position you have to be sure about which it is relative to.

    Suppose you want it relative to a div. Make that div's style like this

    <div style="position: relative;">
    // other codes here
    </div>