我将继续练习 HTML 和 CSS。我正在尝试使图像进入页面的宽度,在标题下方居中。出于某种原因,当我尝试拉伸它时它不起作用。我的猜测是,我还没有遇到这样做的选项。
CSS
#header {
height: 80px;
background-color: gray;
margin-bottom: 60px;
}
.container {
}
.MainImage {
background-image:url(computers.jpg);
height: 400px;
background-repeat: no-repeat;
width: 100%;
}
.MainImage img {
position: relative;
background-size: cover;
}
HTML
<body>
<div id = "header">
<div class = "nav">
<!-- container-fluid gives full width container of whole viewport -->
<div class = "container-fluid">
<ul id = "nav" class= "text-left">
<li><a href = "#"><strong>Home</a></li>
<li><a href = "#">Technologies</a></li>
<li><a href = "#">Programs</a></li>
<li><a href = "#">Blog</strong></a></li>
</ul>
<ul id = "nav" class = "text-right">
<li><a href = "#"><strong>Sign Up</a></li>
<li><a href = "#">Sign In</a></li>
<li><a href = "#">Contact</strong></a></li>
</ul>
</div><!-- end container-fluid-->
</div><!--end nav-->
</div> <!-- end header -->
<div id = "Main">
<div class = "MainImage">
</div>
</div><!--end Main-->
</body>
更新:我的 IE 10 图像错误