Results 1 to 2 of 2

Thread: Stretch background image in CSS

  1. #1
    Join Date
    May 2007
    Posts
    66
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Stretch background image in CSS

    How can I automatically stretch a sidebar background image to the bottom in css? Here is an example in w3schools but I could not get it to work on the site I am working on. Please advise. Thanks

    https://www.w3schools.com/cssref/try...ackground-size

    border: 2px solid black;
    padding: 25px;
    background: url(mountain.jpg);
    background-repeat: no-repeat repeat;

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,815
    Thanks
    48
    Thanked 237 Times in 230 Posts
    Blog Entries
    55

    Default

    Left:
    Code:
    position: absolute;
    left:0; 
    top:0; 
    bottom:0; 
    width: 200px;
    border: 2px solid black;
    padding: 25px;
    background: url(mountain.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    Right:
    Code:
    position: absolute;
    top:0; 
    right:0; 
    bottom:0; 
    width: 200px;
    border: 2px solid black;
    padding: 25px;
    background: url(mountain.jpg);
    background-repeat: no-repeat;
    background-size: cover;

Similar Threads

  1. Stretch image in css
    By hemi519 in forum CSS
    Replies: 2
    Last Post: 01-27-2011, 06:12 PM
  2. Stretch table background?
    By liamallan in forum CSS
    Replies: 1
    Last Post: 08-20-2010, 12:44 PM
  3. Resolved CSS Need to stretch a background image 100% length of page
    By revisedcode in forum CSS
    Replies: 4
    Last Post: 02-01-2009, 08:10 AM
  4. DHTML Slide Show Script image stretch in safari
    By rkk in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 09-10-2007, 02:29 AM
  5. stretch bg image
    By codejunkie in forum CSS
    Replies: 3
    Last Post: 07-13-2005, 08:34 PM

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
  •