我有一个图像 - 加载图像.
我希望该图像显示在页面的中心.我怎样才能做到这一点?
我写的代码是:
img.loading
{
position:absolute;
left:0px;
top:0px;
z-index:1;
}
Run Code Online (Sandbox Code Playgroud)
如何使此图像始终显示在页面中央?
CD.*_*D.. 23
发现这个:如何在CSS中完美地居中图像,可能会有所帮助.
#img
{
position:absolute;
width:592px; /*image width */
height:512px; /*image height */
left:50%;
top:50%;
margin-left:-296px; /*image width/2 */
margin-top:-256px; /*image height/2 */
}
Run Code Online (Sandbox Code Playgroud)
见W3C
IMG.displayed {
display: block;
margin-left: auto;
margin-right: auto
}
<IMG class="displayed" src="..." alt="...">
Run Code Online (Sandbox Code Playgroud)