Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想显示图像 div 的预加载图像中心。但是所有图像都有不同的大小,因此预加载图像不能显示在每个图像的中心。
感谢提前!
您可以使用 css 来解决此问题。将类“预加载器”添加到页面上的每个图像,并用 css 描述它:
.pre-loader { background: #ccc url(loaderimageurl) center center no-repeat; }
然后像这样使用js:
$("img").load(function () { $(this).removeClass("pre-loader"); });