Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- JS
- $(window).resize(function(){
- resize();
- });
- function resize(){
- $('.backgroundImage').each(function(){
- var backgroundImage = $(this);
- var imageWidth = backgroundImage.width();
- var imageHeight = backgroundImage.height();
- var windowWidth = $(window).width();
- var windowHeight = $(window).height();
- if(imageWidth>windowWidth){
- var newWidth = -(imageWidth - windowWidth)/2;
- backgroundImage.css('margin-left', newWidth);
- };
- if(imageHeight>windowHeight){
- var newHeight = -(imageHeight - windowHeight)/2;
- backgroundImage.css('margin-top', newHeight);
- };
- });
- };
- */
- /*
- HTML
- <div class="image_container">
- <img src="img/bg_1.jpg" alt="alt" class="backgroundImage"/>
- </div>
- */
- /*
- CSS
- !important
- body, html {width: 100%; height: 100%;}
- .image_container {
- position: absolute;
- left: 0px:
- top: 0px;
- width: 100%;
- height: 100%;
- z-index: 0;
- overflow: hidden;
- }
- .image_container>img {
- display: block;
- min-height: 100%;
- min-width: 100%;
- position: absolute;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment