简体   繁体   中英

rails css setting background image

main.css

body{
    width:100%;
    height:100%;
    overflow:hidden;
    background:url('/assets/background-calculations.png');
}
body #content{
    z-index:5;
    background:url('/assets/handwritten-text.png');
//  background:white;
    width:100%;
    height:100px;
}
body #footer,#header{
    height:100px;
    width:100%;
    margin:0 auto;
}

index.html.erb is blank

doubt

when i uncomment background:white; in content css its working but when i set the background url its not working , but the same url does not work if i set it for the content div , please help

if you work in a ruby-on-rails, you have a assets > images. put images in there.

In your stylesheets folder (assets > stylesheets) you have to point to the image, not the folder and image:

body{
    width:100%;
    height:100%;
    overflow:hidden;
    background:url(background-calculations.png);
}
body #content{
    z-index:5;
    background:url(handwritten-text.png);
    width:100%;
    height:100px;
}

Ruby-on-rails knows where your images are

Try something like;

body #content{
    z-index:5;
    background-image:url('/assets/handwritten-text.png');
    background-color:white;
    width:100%;
    height:100px;
}

Here is a working live demo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM