如何扩展图像高度以适应我的整个屏幕?

时间:2015-05-24 02:58:16

标签: javascript jquery html css carousel

这是我的主页

我想扩展图像的高度以适应整个屏幕。我知道我必须调整height属性,我这样做,似乎没有任何效果。

CSS

.hero {
  background: #fff;
  border-bottom: 8px solid #7ac9ed;
  background: url('../img/hero-slider/boxfill2sm.jpg');
  background-size: cover;
  position: relative;
  padding-top: 0;
  height: auto;
}

注意:我尝试了height: auto;。它没有做任何事情。

HTML

<section class="hero">
    <div class="container-fluid no-margin no-padding">

        <div class="col-md-8 col-sm-12 col-xs-12 col-lg-8" id="hero-left">
            <div>

                <div class="row">
                    <div class="bx-wrapper" style="max-width: 100%;"><div class="bx-viewport" style="width: 100%; overflow: hidden; position: relative; height: 391px;"><div class="hero-slider" style="width: auto; position: relative;">
                        <div class="slide first-slide" style="float: none; list-style: none; position: absolute; width: 1067px; z-index: 50; display: block;">

                            <div class="col-lg-5 col-md-5 col-sm-5 animated fadeInUp fadeInDown">
                                <h2 style="margin-top:50px;" class="text-left">MEET TUTTI.ED</h2>
                                <p>EFFECTIVE DIGITAL LEARNING</p>
                                <p>Tutti.ed is our educational software platform that empowers education companies to bring state-of-the-art digital learning products to market quickly.</p>
                                <a class="btn btn-primary" href="/tutti-ed">Learn More</a>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 animated fadeInRight">
                                <!--                                <div class="video"><img class="slider-img pull-right" src="img/hero-slider/tdApp1.jpg" width="689" height="659" alt="Components and Styles"/></div> -->
                                <!--                            <img class="iphone" src="img/hero-slider/iphone.png" width="649" height="400" alt="Coming Soon Page"/> -->
                            </div>

                        </div>
                        <div class="slide" style="float: none; list-style: none; position: absolute; width: 1067px; z-index: 0; display: none;">

                            <div class="col-lg-5 col-md-5 col-sm-5 animated fadeInUp">
                                <h2 style="margin-top:50px;" class="text-left">MEET TUTTI.DEV</h2>
                                <p>BY DEVELOPERS, FOR DEVELOPERS</p>
                                <p>Tutti.dev is our cloud application suite that enables software teams to work more effectively and efficiently.  Get it together with Tutti!</p>
                                <a class="btn btn-primary" href="/tutti-dev">Learn more</a>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 animated fadeInRight">
                                <!--                                <div class="video"><img class="slider-img pull-right" src="img/hero-slider/tdApp1.jpg" width="689" height="659" alt="Components and Styles"/></div> -->
                            </div>

                        </div>
                        <div class="slide" style="float: none; list-style: none; position: absolute; width: 1067px; z-index: 0; display: none;">

                            <div class="col-lg-5 col-md-5 col-sm-5 animated fadeInUp">
                                <h2 style="margin-top:70px;" class="text-left">WHY AVENIROS?</h2>
                                <p>Our team has been building content delivery platforms for over 20 years.  We have experience with development from large scale LMS installations to mobile applications.  We can offer full turn-key technical services for your content or help your technical team get to market on time.
                                </p>
                                <a class="btn btn-primary" href="#" data-scrollto="#about">About us</a>
                            </div>
                            <div class="col-lg-7 col-md-7 col-sm-7 animated fadeInRight">
                                <div class="video">
                                    <!--                                    <img class="slider-img pull-right" src="img/hero-slider/tdApp1.jpg" width="689" height="659" alt="Components and Styles"/> -->
    <!--
                                    <img src="img/hero-slider/macbook.png" width="782" height="422" alt=""/>
                                    <div class="vide-holder">
                                        <iframe src="//player.vimeo.com/video/79036490?byline=0&amp;portrait=0&amp;color=ffeeac" width="720" height="405"></iframe>
                                    </div>
                                -->
                            </div>
                        </div>

                    </div>
                </div></div><div class="bx-controls bx-has-pager"><div class="bx-pager bx-default-pager"><div class="bx-pager-item"><a href="" data-slide-index="0" class="bx-pager-link active">1</a></div><div class="bx-pager-item"><a href="" data-slide-index="1" class="bx-pager-link">2</a></div><div class="bx-pager-item"><a href="" data-slide-index="2" class="bx-pager-link">3</a></div></div></div></div>
            </div>


        </div>
    </div>



    <!--Hero Slider-->
    <div class="  col-xs-12 col-sm-12 col-md-4 col-lg-3 pull-right" id="hero-right" style="height: 496px;">

        <div>
            <div>

                <div class="animated fadeInLeft">
                    <h1>Learnosity</h1>
                    <p>Did you know we are partnered with learnosity?</p>
                    <p>To learn more click the button below..filler. </p>
                    <a class="btn btn-primary" href="#">Learnosity</a>
                </div>
            </div>

        </div>

        <!--Close Hero Slider-->
    </div>
</div>
</section>

3 个答案:

答案 0 :(得分:1)

您需要确定屏幕高度,以便更好地使用screen.height 可以使用jQuery访问。此外,如果您使用$( window ).height();,则可以使用$(document).ready(function() { h=$(window).height(); $('.hero').css({'height':h+'px'}); });

获取此属性
auto increment

答案 1 :(得分:1)

    .hero {
  background: #fff;
  border-bottom: 8px solid #7ac9ed;
  background: url(j.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  position: relative;
  padding-top: 0;
  height: 100%;
  width: 100%
}

答案 2 :(得分:1)

这应该有效

   .hero {
  background: #fff;
  border-bottom: 8px solid #7ac9ed;
  background: url(j.jpg) no-repeat center center fixed; 
  -webkit-background-size: 100% 100%;
  -moz-background-size: 100% 100%;
  -o-background-size: 100% 100%;
  background-size: 100% 100%;
  position: relative;
  padding-top: 0;
  height: 100%;
  width: 100%
}