SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How to give full-stretchded background for each part of the page

    I want to create a front page with background stretched to full page width for each section like on this web site: Eshbeata.com

    Anyone has an idea how to do something like this.

    The page I want to create is part of CMS system (wordpress). Each section needs to has dynamic height, but that is not important. I want to have the background clearly separated for different section.

    Thank you,

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,355
    Mentioned
    179 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    If you are talking about this image then its not stretched at all. It's just a very large image of 2500px centred on the screen. On my 27" imac at full screen you get blank gaps at the side as the imac is wider than 2500px.

    You can stretch images for modern browsers just by using background-size:cover and the image will be stretched to fit the container while maintaining the correct aspect ratio.

  3. #3
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,513
    Mentioned
    61 Post(s)
    Tagged
    2 Thread(s)
    ketting00,

    You asked for ideas.
    I don't do WordPress, so you will have to decide if this is useful or not.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>full-width section backgrounds</title>
    <!--
    How to give full-stretchded background for each part of the page
    2014.04.04 04:36
    ketting00
    -->
        <style type="text/css">
    *, *:before, *:after {
        -webkit-box-sizing:border-box;
        -moz-box-sizing:border-box;
        box-sizing:border-box;
    }
    
    body {
        background:#eee;    /* testing. can be deleted. */
        padding:0;
        margin:0;
    }
    
    .one {background:#fca;}    /* testing. can be changed. */
    .two {
        background:url("http://eshbeata.com/images/backgrounds/land.jpg") no-repeat 50% 50% #bdf;
        background-size:cover;
    }
    .three {background:#dea;}    /* testing. can be changed. */
    
    .section {
        max-width:960px;          /* testing. can be changed. */
        min-height:100px;                /* testing. can be deleted. */
        border-left:2px dashed white;    /* testing. can be deleted. */
        border-right:2px dashed white;   /* testing. can be deleted. */
        padding:0 16px;
        margin:0 auto;
    }
    
    .cf:before,
    .cf:after {
        content:"";
        display:table;
        line-height:0;
    }
    .cf:after {
        clear:both;
    }
        </style>
    </head>
    <body>
    
    <div class="one">
        <div class="section cf">
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
        </div>
    </div>
    <div class="two">
        <div class="section cf">
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
        </div>
    </div>
    <div class="three">
        <div class="section cf">
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
        </div>
    </div>
    
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •