LoginSignup
7
4

More than 5 years have passed since last update.

background imageをプリロードする方法

Posted at

ページにCSS animationを設定した際に、backgroundのロードに時間がかかってしまい、アニメーションが不自然になってしまったので、背景画像を先にプリロードしたいと思います。

html
<head>
  <link rel="preload" as="image" href="background.png">
  <link rel="stylesheet" href="style.css">
</head>

これで、background.pngをプリロードできるので、cssのanimationが動く前に画像を読み込むことができます。

7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4