The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › [Solved] Auto width of a background image.
I am trying something a little different, and would like to know if there is a way I can use a larger image and have it resized to fit into the background by using width: 100% in the code shown below.
#painting{ position: relative; top: 10px; left: 90px; width: 800px; height: 533px; background-image: url("spring-800x533.jpg"); background-repeat: no-repeat; }
Try looking into background-size:cover or background-size:contain.
background-size:cover
background-size:contain
Also background-position depending on what you are actually trying to so.
background-position
Thank you Paulie. I will check this out.
Edit: This worked perfect.
background-size: 800px 533px;
I can’t seem to keep up with all the changes in CSS.