How to center images on a web page for all screen sizes

删除回忆录丶 提交于 2019-12-03 09:27:17

Would it not be acceptable to use just a simple <center></center> tag?

I must be missing something here if not. Feel free to explain why in a comment. I love webdesign and your site is very impressive. I might suggest doing something to lower the load time, that is a bit of a turn off.

-From one MC fan to another :)

EDIT

I just took a look at your code... ouch!

<center></center> 

<center><body onload="MM_preloadImages('../logo-glow.png')"> 
<a href="homepage.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('minecraft2','','../logo-glow.png',1)"><img src="../log-noglow.png" name="minecraft2" width="998" height="222" hspace="0" border="0" align="absmiddle" id="minecraft2" /></a></body></center> 

Try not to put formatting tags outside of the body. Place the <center> inside of the body tag. It works because it follows the low level strict rules of HTML, however, not all browsers are this nice and some might display your page incorrectly unless this problem is fixed!

Try something like this...

<div id="wrapper" style="width:100%; text-align:center">
<img id="yourimage"/>
</div>

In your specific case, you can set the containing a element to be:

a {
    display: block;
    text-align: center;
}

JS Bin demo.

<div style='width:200px;margin:0 auto;> sometext or image tag</div>

this works horizontally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!