【发布时间】:2018-01-16 12:25:24
【问题描述】:
我为background 制作了完整的width 和height,动画慢慢地变成了zoom in。问题是,无论我在这个背景上放什么,它都会放大。我试图制作相反的动画来平衡效果,但这不是很干净的解决方案。你知道任何只为背景设置动画的好方法吗?
<header class="header">
<div class="header-text">
<h1>Welcome to the Milky Way</h1>
</div>
</header>
*{
padding: 0;
margin: 0;
box-sizing: border-box;
html, body{
height: 100%;
overflow: hidden;
.header{
display: flex;
justify-content: center;
align-items: center;
min-height: 100%;
width: 100%;
background-color: #333;
background:linear-gradient(
rgba(0, 0, 0, 0.5),
rgba(0, 0, 0, 0.5)
),url('bg.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
animation-name: bg;
.header-text{
color: white;
animation-name: bg-text;
.header, .header-text{
animation-duration: 60s;
animation-timing-function: linear;
animation-fill-mode: forwards;
@keyframes bg{
0%{transform: scale(1)}
100%{transform: scale(1.5)}
@keyframes bg-text{
0%{transform: scale(1)}
100%{transform: scale(0.666)}
【问题讨论】: