我有這樣的:引導主頁上完整的圖像
_layout:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - LolaBikeMen</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
@*<span class="icon-bar"></span>
<span class="icon-bar"></span>*@
<span class="icon-bar"></span>
</button>
@Html.ActionLink("LolaBikeMen", "Index", "Home", null, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<br />
<ul class="nav navbar-nav">
@*<li>@Html.ActionLink("Home", "Index", "Home")</li>*@
<li class="nav ">@Html.ActionLink("WHO", "About", "Home")</li>
<li class="nav ">@Html.ActionLink("WHAT", "Index", "Student")</li>
<li class="nav ">@Html.ActionLink("AGENDA", "Index", "Course")</li>
<li class="nav">@Html.ActionLink("PHILOSPY", "Index", "Instructor")</li>
<li class="nav">@Html.ActionLink("BUCKET-LIST", "Index", "Department")</li>
<li class="nav">@Html.ActionLink("LolaRiders", "Index", "LolaBiker")</li>
<li class="nav">@Html.ActionLink("bycicle", "Index", "Bycicle")</li>
@*<li class="nav"> @Html.Partial("_LoginPartial")</li>*@
</ul>
</div>
</div>
</div>
@*<li class="nav"><img src="~/Images/LolabikesCoffeeLogo3.jpg"> </li>*@
<div class="container">
@RenderBody()
@*<footer>
<p>© @DateTime.Now.Year - LolaBikeMen</p>
</footer>*@
</div>
@*<div class="fill">
</div>*@
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/Cyborg-bootstrap.min")
@RenderSection("scripts", required: false)
</body>
</html>
CSS:
/* Move down content because we have a fixed navbar that is 50px tall */
.container{
/*background-color:MenuText;*/
}
.container2{
width:100%;
height:100%;
}
body {
padding-top: 90px;
padding-bottom: 20px;
}
html {
background: url(~/Images/Large.JPG) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.wrapper {
background-image: url(../Images/Large.JPG);
background-repeat: no-repeat;
background-size: 100% 100%;
width: 100%;
height: 100%;
}
.wide {
width:100%;
height:1000px;
background-image:url('../Images/Large.JPG');
background-size:cover;
}
.wide img {
width:100%;
}
navbar{
color:white;
}
.table-striped>tr>td:nth-child(odd)>td,
.table-striped>tr>td:nth-child(odd)>td {
background-color:white;
}
.table.table-condensed tr th {
border-top: 1px solid white;
}
.table.table-condensed tr th {
border-bottom: 1px solid white;
}
.a:hover, a:focus {
color:floralwhite;
text-decoration: underline;
}
a {
color:floralwhite;
text-decoration: none;
}
.table.table-condensed tr td {
border-bottom: 1px solid white; /* Change the color you want to set */
}
.wrapper {
width: 100%;
background-color: lightcyan;
}
img {
background-image: url('../Images/Large.JPG');
background-repeat: no-repeat;
background-position:top;
background-size:cover;
width: 100%;
height: 100%;
}
/**/
#map {
height: 100%;
width: 100%;
}
#map img {
max-width: 100%;
}
html, body {
height: 100%;
width: 100%;
}
.fullscreen,
.content-a {
width:100%;
min-height:100%;
}
.background {
background-repeat:no-repeat;
/* custom background-position */
background-position:50% 50%;
/* ie8- graceful degradation */
background-position:50% 50%\9 !important;
}
.fill {
top: -30px;
left: 0;
right: 0;
bottom: 0;
position:relative;
/*overflow-x;*/
width:100%;
height:100%;
}
html,body{height:100%;}
.carousel,.item,.active{height:100%;}
.carousel-inner{height:100%;}
.fill{width:100%;height:100%;background-position:center;background-size:cover;}
.navbar {
margin-bottom: 0;
}
/* Demo */
#map { background:black; }
/**/
/* Wrapping element
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set widths on the form inputs since otherwise they're 100% wide */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="select"] {
max-width: 280px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
.jumbotron {
margin-top: 20px;
}
.body-content {
padding: 0;
}
}
而且INdex.cshtml(主頁):
@{
ViewBag.Title = "Home Page";
}
<div class="container2 fill">
<div id="map">
<img src="~/Images/VeryLarge.JPG" class="img-responsive" alt="Responsive image">
</div>
</div>
<!--1st Large Banner Image -->
@*<div class="wrapper">
<img src="~/Images/Large.JPG" class="img-responsive" alt="Responsive image">
<div class="col-sm-6">
@*<h1 id="text">Hello World!</h1>*@
@*<div class="jumbotron hidden-sm" >
<img src="~/Images/IMG_4954 - Copy.JPG">
</div>*@
<script type="text/javascript">
$('.carousel').carousel();
</script>
所以在主頁上我有一個大的圖像。但它沒有填滿孔的寬度。而且高度不會填滿整個屏幕。我希望如果你使屏幕變小,那麼圖像將會裁剪 - 這取決於屏幕的尺寸。在其餘的頁面中,我不想使用整個寬度。所以我不能離開這一點,這一點在_Layout.cshtml:
<div class="container">
@RenderBody()
@*<footer>
<p>© @DateTime.Now.Year - LolaBikeMen</p>
</footer>*@
</div>
謝謝
奧凱,我加了這一點:在的site.css:
.background {
background: url(../Images/Large.JPG) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
但會有怎樣的Index.cshtml頁面看起來像那麼?
這樣的:
<div class="background">
</div>
如果我將鼠標懸停我的鼠標在這條線:
-webkit-background-size: cover;
我得到這個消息:
警告87驗證(WE):「-webkit -background-size「不是有效的供應商特定屬性,或者可能已被棄用。 G:\ Mijn Documents \我的網站\ Lolabikes \ C#\ ContosoUniversity \內容\全寬pics.css 14 5 Lolabike
奧凱,我有現在這樣的:
的site.css:
body {
background-image: url('../Images/Large.JPG');
background-repeat: no-repeat;
background-attachment: fixed;background-size: 100%;
/*padding-top: 90px;
padding-bottom: 20px;*/
}
和index.cshtml:
<div class="container fill">
<div id="map">
</div>
</div>
OKE,但它現在正對所有的網頁:(
而不僅僅是在主頁上。大圖像只能在主頁上看到,而不能在其他頁面上看到。
謝謝
,如果我不喜歡這樣寫道:
/* Move down content because we have a fixed navbar that is 50px tall */
.container{
/*background-color:MenuText;*/
}
.container2{
width:100%;
height:100%;
}
body {
/*padding-top: 90px;
padding-bottom: 20px;*/
}
/*html {
background: url(~/Images/Large.JPG) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}*/
.wrapper {
background-image: url(../Images/Large.JPG);
background-repeat: no-repeat;
background-size: 100% 100%;
width: 100%;
height: 100%;
}
.wide {
width:100%;
height:1000px;
background-image:url('../Images/Large.JPG');
background-size:cover;
}
.wide img {
width:100%;
}
navbar{
color:white;
}
.table-striped>tr>td:nth-child(odd)>td,
.table-striped>tr>td:nth-child(odd)>td {
background-color:white;
}
.table.table-condensed tr th {
border-top: 1px solid white;
}
.table.table-condensed tr th {
border-bottom: 1px solid white;
}
.a:hover, a:focus {
color:floralwhite;
text-decoration: underline;
}
a {
color:floralwhite;
text-decoration: none;
}
.table.table-condensed tr td {
border-bottom: 1px solid white; /* Change the color you want to set */
}
.wrapper {
width: 100%;
background-color: lightcyan;
}
img {
background-image: url('../Images/Large.JPG');
background-repeat: no-repeat;
background-position:top;
background-size:cover;
width: 100%;
height: 100%;
}
/**/
#map {
height: 100%;
width: 100%;
}
#map img {
max-width: 100%;
}
html, body {
height: 100%;
width: 100%;
}
.fullscreen,
.content-a {
width:100%;
min-height:100%;
}
.background {
background-image: url('../Images/Large.JPG');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100%;
}
.fill {
top: -30px;
left: 0;
right: 0;
bottom: 0;
position:relative;
/*overflow-x;*/
width:100%;
height:100%;
}
html,body{height:100%;}
.carousel,.item,.active{height:100%;}
.carousel-inner{height:100%;}
.fill{width:100%;height:100%;background-position:center;background-size:cover;}
.navbar {
margin-bottom: 0;
}
/* Demo */
#map { background:black; }
/**/
/* Wrapping element
/* Set some basic padding to keep content from hitting the edges */
.body-content {
padding-left: 15px;
padding-right: 15px;
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set widths on the form inputs since otherwise they're 100% wide */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="select"] {
max-width: 280px;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
.jumbotron {
margin-top: 20px;
}
.body-content {
padding: 0;
}
}
,並在index.cshtml:
<div class="background"></div>
,我在看鉻(F12):
Remote Address:::1:41787
Request URL:http://localhost:41787/Images/Large.JPG
Request Method:GET
Status Code:200 OK (from cache)
但圖像不顯示y at。
嗨Neutrion感謝您的answare,你看我的編輯? – 2014-10-02 16:32:18
我已編輯我的問題。謝謝你 – 2014-10-02 17:08:43
?有人幫助嗎?謝謝 – 2014-10-03 06:58:33