Search code examples
htmlcssimagestyles

Can't add a picture from my computer to css styling


I can't add a file from my computer to use for my background on my website. Can only use URLs. How can I get the local file added?

Can't add local file on Line 18


Solution

  • because you are setting width to 100% instead use a px or rem value.100% means 100% of its parent & i assume it doesn't have a parent.

     div {
                height: 320px;
                width: 240px;
                background: url(https://upload.wikimedia.org/wikipedia/commons/c/c9/-Insert_image_here-.svg);
                background-position: center;
                background-repeat: no-repeat;
                background-size: contain;
            }
    <div></div>