css - Full-screen responsive background image -
i new front-end development , foundation.
i trying <div class="main-header">
full screen image scales down responsively.
can tell me doing wrong? scaling properly, not showing full image. wanted <div class="large-6 large-offset-6 columns">
sit above on mobile device – possible?
the html:
<!-- main header --> <div class="main-header"> <div class="row"> <div class="large-6 large-offset-6 columns"> <h1 class="logo">bleepbleeps</h1> <h3>a family of little friends<br>that make parenting easier</h3> </div> <!-- end large-6 large-offset-6 columns --> </div><!-- end row --> </div><!-- end main-header -->
the css:
.main-header { background-image: url(../img/bb-background2.png); background-repeat: no-repeat; background-position: center; background-size: cover; width: 100%; height: 100%; } h1.logo { text-indent: -9999px; height:115px; margin-top: 10%; }
http://css-tricks.com/perfect-full-page-background-image/
//html <img src="images/bg.jpg" id="bg" alt=""> //css #bg { position: fixed; top: 0; left: 0; /* preserve aspet ratio */ min-width: 100%; min-height: 100%; }
or
img.bg { /* set rules fill background */ min-height: 100%; min-width: 1024px; /* set proportionate scaling */ width: 100%; height: auto; /* set positioning */ position: fixed; top: 0; left: 0; } @media screen , (max-width: 1024px) { /* specific particular image */ img.bg { left: 50%; margin-left: -512px; /* 50% */ } }
or
//html <img src="images/bg.jpg" id="bg" alt=""> //css #bg { position: fixed; top: 0; left: 0; } .bgwidth { width: 100%; } .bgheight { height: 100%; } //jquery $(window).load(function() { var thewindow = $(window), $bg = $("#bg"), aspectratio = $bg.width() / $bg.height(); function resizebg() { if ( (thewindow.width() / thewindow.height()) < aspectratio ) { $bg .removeclass() .addclass('bgheight'); } else { $bg .removeclass() .addclass('bgwidth'); } } thewindow.resize(resizebg).trigger("resize"); });
Comments
Post a Comment