Background_resize

by Koubenec

HTML

<script type="text/javascript">
/*
 * jQuery Backstretch
 * Version 1.2.7
 * http://srobbin.com/jquery-plugins/jquery-backstretch/
 *
 * Add a dynamically-resized background image to the page
 *
 * Copyright (c) 2012 Scott Robbin (srobbin.com)
 * Licensed under the MIT license
 * https://raw.github.com/srobbin/jquery-backstretch/master/LICENSE.txt
 * 
*/
;(function(a){a.backstretch=function(p,b,l){function s(){if(p){var b;0==c.length?c=a("<div />").attr("id","backstretch").css({left:0,top:0,position:m?"fixed":"absolute",overflow:"hidden",zIndex:-999999,margin:0,padding:0,height:"100%",width:"100%"}):c.find("img").addClass("deleteable");b=a("<img />").css({position:"absolute",display:"none",margin:0,padding:0,border:"none",zIndex:-999999}).bind("load",function(d){var b=a(this),e;b.css({width:"auto",height:"auto"});e=this.width||a(d.target).width();d=this.height||a(d.target).height();n=e/d;q();b.fadeIn(g.speed,function(){c.find(".deleteable").remove();"function"==typeof l&&l()})}).appendTo(c);0==a("body #backstretch").length&&(0===a(window).scrollTop()&&window.scrollTo(0,0),a("body").append(c));c.data("settings",g);b.attr("src",p);a(window).unbind("resize.backstretch").bind("resize.backstretch",function(){"onorientationchange"in window&&window.pageYOffset===0&&window.scrollTo(0,1);q()})}}function q(){try{j={left:0,top:0},rootWidth=h=o.width(),rootHeight=r?window.innerHeight:o.height(),f=h/n,f>=rootHeight?(k=(f-rootHeight)/2,g.centeredY&&(j.top="-"+k+"px")):(f=rootHeight,h=f*n,k=(h-rootWidth)/2,g.centeredX&&(j.left="-"+k+"px")),c.css({width:rootWidth,height:rootHeight}).find("img:not(.deleteable)").css({width:h,height:f}).css(j)}catch(a){}}var t={centeredX:!0,centeredY:!0,speed:0},c=a("#backstretch"),g=c.data("settings")||t;c.data("settings");var o,m,r,n,h,f,k,j;b&&"object"==typeof b&&a.extend(g,b);b&&"function"==typeof b&&(l=b);a(document).ready(function(){var...

CSS

#logoplace {
    width: 200px;
    height: 200px;
    background-color: red;
    margin-left: auto;
    margin-right: auto;
}

#navcontainer {
    height: 30px;
    width: 80%;
    background-color: white;
    margin: 5px auto;
    opacity: 0.7;
}

#navcontainer:hover {
    opacity: 1;
}

#rowone {
    width: 80%;
    height: 120px;
    background-color: transparent;
    margin: 5px auto;
}

#rowoneone {
    width: 50%;
    height: 120px;
    background-color: green;
    float: left;
}

#rowonetwo {
    width: 50%;
    height: 120px;
    background-color: blue;
    float: right;
    position: relative;
    left: 5px;
}

#rowonewrapper {
    margin-right: 5px;
}

html, body
{
    height: 100%;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Ticker Styling */
.ticker-wrapper.has-js {
    margin: 5px auto;
    padding: 0px 0px;
    width: 80%;
    height: 32px;
    display: block;
    background-color: #f8f0db;
    font-size: 0.75em;
}
.ticker {
    width: 70%;
    height: 23px;
    display: block;
    position: relative;
    overflow: hidden;
    background-color: #f8f0db;
}
.ticker-title {
    padding-top: 9px;
    color: #990000;
    font-weight: bold;
    background-color: #f8f0db;
    text-transform: uppercase;
}
.ticker-content {
    margin: 0px;
    padding-top: 9px;
    position: absolute;
    color: #1F527B;
    font-weight: bold;
    background-color: #f8f0db;
    overflow: hidden;
    white-space: nowrap;
    line-height: 1.2em;
}
.ticker-content:focus {
    none;
}
.ticker-content a {
    text-decoration: none;    
    color: #1F527B;
}
.ticker-content a:hover {
    text-decoration: underline;    
    color: #0D3059;
}
.ticker-swipe {
    padding-top: 9px;
    position: absolute;
    top: 0px;
    background-color: #f8f0db;
    display: block;
    width: 800px;
    height: 23px; 
}
.ticker-swipe span {
    margin-left: 1px;
    background-color: #f8f0db;
    border-bottom: 1px solid #1F527B;
   ...

JavaScript

$(function(){
    $.backstretch("http://farm6.staticflickr.com/5096/5527324327_f971b399f4_b_d.jpg");
})
    
$(function () {
     // start the ticker 
    $('#js-news').ticker();
    
    // hide the release history when the page loads
    $('#release-wrapper').css('margin-top', '-' + ($('#release-wrapper').height() + 20) + 'px');

    // show/hide the release history on click
    $('a[href="#release-history"]').toggle(function () {    
        $('#release-wrapper').animate({
            marginTop: '0px'
        }, 600, 'linear');
    }, function () {
        $('#release-wrapper').animate({
            marginTop: '-' + ($('#release-wrapper').height() + 20) + 'px'
        }, 600, 'linear');
    });    
    
    $('#download a').mousedown(function () {
        _gaq.push(['_trackEvent', 'download-button', 'clicked'])        
    });
});

// google analytics code
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6132309-2']);
_gaq.push(['_setDomainName', 'www.jquerynewsticker.com']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();