我正在尝试这种布局
我已将此代码用于背景图片
<div class="container-fluid" style="padding: 0px;">
<img class="img-responsive center-block header1" src="images/header.jpg" />
</div>
之后,我不知道如何使用引导程序将徽标或导航栏放在背景图像上,如上图所示。
任何人都可以告诉我将使用哪个引导类或标记?或者我是否必须使用自定义CSS?
提前致谢。
答案 0 :(得分:2)
尝试下面的内容,
您可以使用css设置background-image
。此外,我建议您使用此功能,因为如果您在响应中生成元素absolute
,则会出现问题。
.img-full {
height: 300px;
background-image: url('http://www.aegisworld.com/wp-content/uploads/2013/06/65-3.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: 100%;
}
.navbar {
margin-top: 20px;
}
.navbar.navbar-default {
background-color: transparent;
border-color: transparent;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="img-full">
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<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" href="#">Project name</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a>
</li>
<li><a href="#">About</a>
</li>
<li><a href="#">Contact</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a>
</li>
<li><a href="#">Another action</a>
</li>
<li><a href="#">Something else here</a>
</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a>
</li>
<li><a href="#">One more separated link</a>
</li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container-fluid -->
</nav>
</div>
</div>
&#13;
答案 1 :(得分:0)
这不是Bootstrap功能,您必须将positition:absolute;
应用于容器DIV,然后使用<div class="container-fluid" style="padding: 0px;">
<img class="img-responsive center-block header1" src="images/header.jpg" />
<div class='inner'>......</div>
</div>
.container-fluid {
position:relative;
}
.inner {
position:absolute;
top:10%;
right:20%;
}
将适当的顶部和左/右偏移用于内部。
img SRC
如果您想保留import UIKit
import WebKit
class AboutViewController: UIViewController, WKNavigationDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let webView = WKWebView()
webView.navigationDelegate = self
let url = NSURL(string: "http://www.yoursite.com")
let request = NSURLRequest(URL: url!)
webView.loadRequest(request)
view = webView
}
func webView(webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
// the page begins to load... do what you want here (maybe an indicator to say it is loading...)
}
func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
// the page is done loading. do what you need here
}
}
用户放置图片的方式,这是正确的。否则你可以将它转换为背景,因此,没有必要的相对/绝对定位,但你必须在DIV上设置一个以此图像为背景的大小(宽度和高度)
答案 2 :(得分:0)
您需要将图像设置为DIV的背景。您可以使用以下CSS来执行此操作。然后,您可以将内容添加到DIV并相应地设置样式/位置
.container-fluid{
background:url('images/header.jpg') no-repeat;
background-size:100% auto;
}
您还需要将DIV的高度设置为图像的高度或所需的高度。