gpt4 book ai didi

javascript - 如何在 Twitter 的 Bootstrap 3 中淡化循环背景图像

转载 作者:行者123 更新时间:2023-11-29 21:42:38 27 4
gpt4 key购买 nike

我正在使用 Twitter 的 Bootstrap 框架(第 3 版)制作一个网站,我想使用由 Roko C. Buljan 制作的很棒的脚本请参阅这篇 StackOverflow 帖子:How to fade loop background images?

这是我的代码:

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="img/favicon.ico">
<title>MY SITE</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/starter-template.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" rel="home" title="PAGE">
<img style="max-width:64px; margin-top: -8px;" src='img/logo.png'>
</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#info"><i class='glyphicon glyphicon-tasks'></i> Info</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="logout.php"><i class='glyphicon glyphicon-lock'></i> Logout</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="fakebg"></div>
<div id='page' class="container">
<div class="starter-template">
<div class="row">
...
</div><!-- row -->
</div><!-- starter template -->
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bgchanger.js"></script>
</body>
</html>

CSS:

html, body, .fakebg
{
background: #000 none 0 50% / no-repeat center center fixed;
overflow:auto !important;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#page
{
overflow:auto !important;
}
.fakebg
{
overflow:auto !important;
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
width:100%;
height:100%;
background: #000 none 50% / cover no-repeat;
}

bgchanger.js 是 Roko 编写的脚本。

问题:我的页面很长(高度),所以背景在一定高度处被切断。当我滚动时会发生这种情况。

我做错了什么?

最佳答案

嗯,原来是需要设置

html, body{ height:100%;}

为了让 .fakebg 将它的大小扩大到 100%(html/body parent)。

关于javascript - 如何在 Twitter 的 Bootstrap 3 中淡化循环背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32236477/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com