Dynamically Changing CSS Background Image

前端 未结 5 431
余生分开走
余生分开走 2020-12-10 05:11

What I\'m looking for is a way to make my HTML header tag change background images every few seconds. Any solutions are welcome, as long as it is not to complex.

I h

5条回答
  •  天命终不由人
    2020-12-10 05:35

    You could acheive this same technique with HTML/CSS Only by 1. placing images within an "img" tag in your HTML surrounded by a "div wrapper" and setting it to position:relative and div wrapper img's to position:absolute. For full-width/full-height you can use percentages or potentially "background-size:cover" (haven't checked) and then call a CSS animation to change the images dynamically.

    Or 2. you can add multiple images to a background in your CSS separated by commas, apply background-size:cover and again use CSS animations to change the background.

    Here's an example and also Mozilla CSS3 Animation Documentation

提交回复
热议问题