html - 与背景图像相比的动画宽度
问题描述
我有一个根据屏幕大小自动调整大小的背景图像。我有一个动画,我试图做同样的事情以保持一致性。但是,动画的宽度似乎不同,也不会延伸到整个屏幕。
body {
height: 100%;
margin: 0;
padding: 0;
background:url(../img/Ex.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
padding-top: 3rem;
outline-style: solid;
outline-color: #ffcd11;
outline-width: thick;
background-color: #ffcd11;
}
.rain {
height: 100%;
margin: 0;
padding: 0;
background:url(../img/snowfall2.png) center center
fixed,url(../img/snowfall3.png) center center fixed;
animation: rain 1s linear infinite;
}
.rain:before {
content: '';
position: absolute;
height: 100%;
background: white;
animation: lighting 4s linear infinite;
opacity: 0;
}
@keyframes lighting {
0%
{
opacity: 0;
}
10%
{
opacity: 0; position: 0% 0%;
}
11%
{
opacity: 1; position: 20% 100%;
}
14%
{
opacity: 0;
}
20%
{
opacity: 0;
}
21%
{
opacity: 1;
}
24%
{
opacity: 0;
}
104%
{
opacity: 0;
}
}
@keyframes rain {
0%
{
background-position: 0% 0%;
}
100%
{
background-position: 20% 100%;
}
}
<div class="carousel-caption rain">
<!-- <h1>Machine Parts Intelligence</h1> -->
<h1 class="lead">THE NEW MACHINE MODEL INFORMATION EXPERIENCE</h1>
</div>
添加了关键帧。我还没有完全让灯光效果按我的意愿工作,但我现在并不真正担心这一点。我只希望雨/雪效果与背景图像本身的宽度相同。
解决方案
我只需要在我的 CSS 中添加以下代码:
.rain {
height: 100%;
margin: 0;
padding: 0;
left: 0;
right: 0;
background:url(../img/snowfall2.png) center center fixed,url(../img/snowfall3.png)
center center fixed;
animation: rain 1s linear infinite;
}
左右功能解决了我的问题,它扩大了我网站的宽度。
推荐阅读
- node.js - console.timeLog() 在开玩笑测试中不起作用
- python - Python: cannot make a HTTPS request using SSL socket
- javascript - 理解 Javascript 中有效回文的解决方案
- unity3d - 为什么我的 PlayerController 脚本中出现 NullReferenceException
- curl - 延迟后的 CURL/WGET
- google-kubernetes-engine - 我如何知道入口控制器返回的 404 错误是否会通过等待自行解决?
- numpy - 如何向量化分割向量的过程
- python - 删除列表中的空元素并将剩余元素转换为浮点数
- python - 随着 Tkinter 试图在 Text() 小部件中打开一个文本文件
- c++ - 在文本中找到半字“ABBA”的问题