所以我使用此背景图片与网站的品牌包保持一致,我已按以下方式设置:
html {
background: url(../img/GreyWeavePaper-Portrait.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
但是当我通过html添加图像(格式为.png并且在背景上是透明的)时,会出现一个大的白色条带。为了解决这个问题,我通过以下方式在CSS中设置了一个背景:
body {
background: url(../img/GreyWeavePaper-Portrait.jpg) no-repeat center center fixed;
margin-top: 80px;
font-family: 'passport', sans-serif;
color: #000;
}
正如您在图像顶部看到的那样,背景设置为html,徽标位于背景与身体设置的位置。有人可以帮我把这个背景设置为当我有内容的时候它就在这张图片的顶部吗?
图像尺寸为300x150
@import url(../fonts/VINCHAND.ttf);
@import url(../fonts/Passport.ttf);
/*!
Main Page CSS || Created By Thomas Withers @ Ice7Media
*/
/* Global Styles
============================================================ */
html {
background: url(../img/GreyWeavePaper-Portrait.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body {
padding-top: 50px;
background: url(../img/GreyWeavePaper-Portrait.jpg) no-repeat center center fixed;
font-family: 'passport', sans-serif;
color: #000;
}
h1,
h2,
h3,
h4,
h5 {
font-family: 'passport', 'Open Sans', sans-serif;
color: #000;
}
p {
font-family: 'passport', sans-serif;
color: #000;
}
#topnavbar {
margin: 0;
}
#topnavbar.affix {
position: fixed;
top: 0;
width: 100%;
}
.banner {
padding-bottom: 50px;
}
.banner img {
display: block;
margin-left: auto;
margin-right: auto
}
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta charset
===================================================================================-->
<meta charset="utf-8">
<!-- Title
===================================================================================-->
<title>Bocaditio | South Amercian Dishes</title>
<!-- Meta Tags
===================================================================================-->
<meta name="author" content="Thomas Withers @ Ice7Media">
<meta name="description" content="Social Media Wizzards that handle all of your social media markerting.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- CSS Stylesheets
===================================================================================-->
<link href = "css/bootstrap.min.css" rel = "stylesheet">
<link href = "css/new_Custom.css" rel = "stylesheet">
<link href = "css/Mapstyle.css" rel = "stylesheet">
<link rel="stylesheet" href="css/animate.css">
<link rel="shortcut icon" href="img/iceBox.png">
<!-- Custom Fonts
===================================================================================-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto+Slab">
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'>
</head>
<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
<!-- Logo Section
===================================================================================-->
<section class="banner" id="banner">
<div class="container">
<div class="row">
<div class="col-lg-12">
<img src="img/BocaditoLogo_113x300.png">
</div>
</div>
</div>
</section>
<!-- Navigation
===================================================================================-->
<nav class="navbar navbar-default navbar-static-top" role="navigation" id="MainNav">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Nav 1</a></li>
<li><a href="#">Nav 2</a></li>
<li><a href="#">Nav 3</a></li>
<li><a href="#">Nav 4</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- container-fluid -->
</nav>
<!-- Full screen Slider
===================================================================================-->
<!-- Welcome Message
===================================================================================-->
<!-- Latest Blog Post
===================================================================================-->
<!-- Three Images
===================================================================================-->
<!-- Map & Conatct
===================================================================================-->
<!-- Footer
===================================================================================-->
<!-- Scripts
===================================================================================-->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC22aNgIjcYzx5Oel1m0Jtcem-W4R895fQ"></script>
<script src="js/jquery.easing.min.js"></script>
<script src="js/fix-nav.js"></script>
<script src="js/main.js"></script>
<script>
$('.carousel').carousel({
interval: 5000 //changes the speed
})
</script>
</body>
</html>
感谢任何帮助
答案 0 :(得分:0)
如果我理解正确,您希望删除body
上的背景,并将background-size
放在html
上。
但是,这也要求您将no-repeat
更改为repeat
,这会导致页面与该图片平铺:
html {
background: url(http://lorempixel.com/g/150/300/) repeat center center fixed;
}
body {
margin-top: 80px;
font-family: 'passport', sans-serif;
color: #000;
}
&#13;
<!DOCTYPE html>
<html>
<body>
Test
</body>
</html>
&#13;
如果您只想垂直重复图片,请改用repeat-y
并设置background-size: 100% auto;
:
html {
background: url(http://lorempixel.com/g/150/300/) repeat-y center center fixed;
-webkit-background-size: 100% auto;
-moz-background-size: 100% auto;
-o-background-size: 100% auto;
background-size: 100% auto;
}
body {
margin-top: 80px;
font-family: 'passport', sans-serif;
color: #000;
}
&#13;
<!DOCTYPE html>
<html>
<body>
Test
</body>
</html>
&#13;
答案 1 :(得分:0)
固定。
@siguza说它可能是一个背景颜色被设置,在检查元素时我发现它是在bootstrap.min.css中设置的,这是我从未想过的......
通过这样做来解决
for idx, vert in enumerate(row):
if vert > 0:
temp[vert].append(idx)
再次感谢Siguza