提问者:小点点

我如何添加一个独立的背景动画?


我正在为学校做这个项目,我需要知道如何使用这个独立的背景动画我做的。

我试着做了一个单独的DIV块,但是到目前为止还没有成功。有人能帮我吗?

这是我当前的代码:

xHTML:

    <head>
        <title>Baseball quiz</title>
        <link href="css/style.css" rel="stylesheet"/>
    </head>
    <body>
        <div class="bg"/>
        <div class="question">
            <h1>Baseball Quiz</h1>
            <h3>Made by Lordust</h3>
            <p>
                <a href="xhtml/question1.xhtml">Click here to start</a>
            </p>
        </div>
    </body>

CSS:

.bg {
    animation: bg;
    animation-direction: normal;
    animation-iteration-count: infinite;
}

@keyframes bg {
  0% {background-color:hsl(180, 100%, 90%)}
  17% {background-color:hsl(240, 100%, 90%)}
  34% {background-color:hsl(300, 100%, 90%)}
  51% {background-color:hsl(0, 100%, 90%)}
  68% {background-color:hsl(60, 100%, 90%)}
  85% {background-color:hsl(120, 100%, 90%)}
  100% {background-color:hsl(180, 100%, 90%)}
}

共1个答案

匿名用户

添加

animation-duration: 4s;

在bg班上。