gpt4 book ai didi

javascript - 在 Bootstrap 中为标题设置全宽背景图像

转载 作者:太空宇宙 更新时间:2023-11-04 14:13:09 25 4
gpt4 key购买 nike

我的问题是如何在 Bootstrap 中为标题设置完整的宽度和高度背景图像,如 http://demo.evenfly.com/view?theme=SantaGo(我不期待动画,我期待如何制作适合屏幕的背景)?

这是我到目前为止所做的,

https://codepen.io/anon/pen/reYRBo

HTML:

<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="sltac.css">
</head>
<body>
<header>
<div class="row">
<div class="bg-image" id="jumboid">
<img src="http://www.visitnorwich.co.uk/assets/Uploads/Events-images/Theatre-generic.jpg" class="img-responsive" alt="Cinque Terre" width="100%" height="40%" back>
</div>
</header>
</body>
</html>

CSS:

body{
margin:0;
padding:0;
width:100%;
}

#jumboid{
width:100% ;

}

.bg-image {
position: relative;
}
.bg-image img {
display: block;
width: 100%;
max-width: 1200px; /* corresponds to max height of 450px */
margin: 0 auto;

}

header{
width:100%;
height:100%;
height:calc(100% - 1px);
background-image:url('a.jpg');
background-size:cover;
}

最后我期待这样的结果(如果我拍摄整页屏幕截图),

expected result

最佳答案

无需使用额外的图片标签。只需设置背景和属性 background-size: cover

像这样尝试:

html,
body {
width: 100%;
height: 100%;
}
header {
width: 100%;
height: 100%;
background: url(http://www.visitnorwich.co.uk/assets/Uploads/Events-images/Theatre-generic.jpg) center center no-repeat;
background-size: cover;
}
<body>

<header>

</header>
</body>

关于javascript - 在 Bootstrap 中为标题设置全宽背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36449636/

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