简体   繁体   中英

positioning an image using HTML

Lets say I have an image and I would like to position it not exactly at the center nor at right, what html code I should be using to do this?

I want to put the exact position I want instead of using center or right or left .

Thanks

Like this?

<img style="position: absolute; right: 30%; top: 25%;" src="http://www.gravatar.com/avatar/e1122386990776c6c39a08e9f5fe5648?s=128&d=identicon&r=PG"/>

http://jsfiddle.net/NVum7/

I think you probably want to learn about CSS positioning:

http://www.alistapart.com/articles/css-positioning-101/

Using margins and Padding via CSS. Look at this link .

I think you have to use at least a little bit of CSS. With inline CSS it is easy to use (but maybe not the best way doing it inline).

So use the style attribute in HTML and set the position with CSS.

style="position:absolute; top:30px; left:10px;"

With position:fixed; ... position:fixed; ... you can set the image always at the same position of your screen, even when you are scolling down the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM