2016-07-26 107 views
-1

我嘗試了幾種不同的方法,但不幸的是我無法找到解決方案 這裏是我的網頁的外觀 http://i.stack.imgur.com/xCAxY.png
這裏是我的CSS如何將我的背景圖像拉伸至整個屏幕?

.first{ 
 
padding-top:0px; 
 
    padding-bottom: 0px; 
 
background: url('../image/background.jpg'); 
 
background-attachment:fixed; 
 
    background-repeat:no-repeat; 
 
    background-size:100% 100%; 
 
    background-position: center; 
 
    position: absolute; 
 
}

這裏是代碼

<div class="first"> 
 
    
 
    <div class="jumbotron" style="margin-left:0px;"> 
 
     <h1>ASP.NET</h1> 
 
     <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p> 
 
     <p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p> 
 
    </div> 
 

 
    <div class="row"> 
 
     <div class="col-lg-4"> 
 
      <h2>Getting started</h2> 
 
      <p> 
 
       ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that 
 
       enables a clean separation of concerns and gives you full control over markup 
 
       for enjoyable, agile development. 
 
      </p> 
 
      <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p> 
 
     </div> 
 
     <div class="col-lg-4"> 
 
      <h2>Get more libraries</h2> 
 
      <p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p> 
 
      <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p> 
 
     </div> 
 
     <div class="col-lg-4"> 
 
      <h2>Web Hosting</h2> 
 
      <p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p> 
 
      <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p> 
 

 
     </div> 
 
    </div> 
 
</div>

+0

我們需要看到完整的規則(它的名字),你的HTML能夠給出一個正確的答案 – LGSon

回答

0

您幾乎沒有提供進一步的信息。如果將CSS應用於body,請確保您在html和body上具有最小高度:100%,並且您可能正在尋找background-size:cover屬性。

0
width: 100vh 
height: 100vh 

background-size: cover 
+0

這也給了相同的結果 –

+0

粘貼你的代碼的jsfiddle 。 –