如何将我的背景图像拉伸到整个屏幕?

时间:2016-07-26 22:22:21

标签: javascript html css twitter-bootstrap

我尝试了几种不同的方法,但不幸的是我找不到解决方案 这是我的页面外观   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>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

您几乎没有提供进一步的信息。如果CSS应用于正文,请确保你在html和body上有min-height:100%,也许你正在寻找background-size:cover属性。

答案 1 :(得分:0)

width: 100vh
height: 100vh

background-size: cover