Log in

View Full Version : Stretch background image in CSS



jcdesigns
01-25-2018, 08:01 PM
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/tryit.asp?filename=trycss3_background-size

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

molendijk
01-26-2018, 12:25 AM
Left:
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:
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;