Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS background without using url

Tags:

css

Is there a way in CSS to include a background without using url()

Ex, I can't do this:

#blah {
    background:url("either image or image data");
}

Is there a workaround where I can achieve the same thing but not using the keyword "url" (The word "url" is prohibited.

like image 896
user3023421 Avatar asked Jul 04 '26 04:07

user3023421


1 Answers

You can use an <img> tag as your background image, no URL in the CSS is necessary. Something like this:

HTML

<img src="image.jpg" class="bg">
<div id="page-wrap">
</div>

CSS

img.bg {
    min-height: 100%;
    min-width: 1024px;
    width: 100%;
    height: auto;
    position: fixed;
    top: 0;
    left: 0;
}

@media screen and (max-width: 1024px) {
    img.bg {
        left: 50%;
        margin-left: -512px;
    }
}

See here for more information and a demo: http://css-tricks.com/perfect-full-page-background-image/

like image 136
Dryden Long Avatar answered Jul 06 '26 12:07

Dryden Long



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!