Forum: Ruby Background image defined in stylesheet doesn't display

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F6715491a2224a42bd2a0d6e290b14ce?d=identicon&s=25 Rubio Ramirez (rubio)
on 2009-04-15 18:22
application.html.erb is correctly finding the stylesheet for my project
via <%= stylesheet_link_tag 'style1' %>.  My webpages reflect the
styling properly with a few exceptions .. the most notable being some
.jpg images defined for background do not display at all.  I have those
images in public/images.

The following is the stylesheet code containing the reference to the
image.

#navigation {
  width: 180px;
  height: 484px;
  background: #7da5a8 url(backgrounds/nav-bg.jpg) no-repeat;
}

This worked fine until I retrofitted the webpages into the Rails
framework (which I really like, but which I'm relative new to).

If anyone knows the solution, I would really appreciate it ... thanks in
advance!

Rubio
34a7615f38496a5dafbb3e6b721c435e?d=identicon&s=25 Mohit Sindhwani (Guest)
on 2009-04-15 18:32
(Received via mailing list)
Rob Blimploid wrote:
> application.html.erb is correctly finding the stylesheet for my project
> via <%= stylesheet_link_tag 'style1' %>.  My webpages reflect the
> styling properly with a few exceptions .. the most notable being some
> .jpg images defined for background do not display at all.  I have those
> images in public/images.
>
>

So, the URL for the images is images/... relative to the path of your
application.

> The following is the stylesheet code containing the reference to the
> image.
>
> #navigation {
>   width: 180px;
>   height: 484px;
>   background: #7da5a8 url(backgrounds/nav-bg.jpg) no-repeat;
> }
If your stylesheet is in public/stylesheets/styles.css [example], then
the relative path to the images directory is:
url(../images/...jpg) or url(../images/backgrounds/image.jpg)
depending on where exactly you placed the files.

Cheers,
Mohit.
4/16/2009 | 12:30 AM.
F6715491a2224a42bd2a0d6e290b14ce?d=identicon&s=25 Rubio Ramirez (rubio)
on 2009-04-15 18:44
Mohit Sindhwani wrote:
If your stylesheet is in public/stylesheets/styles.css [example], then
the relative path to the images directory is:
url(../images/...jpg) or url(../images/backgrounds/image.jpg)
depending on where exactly you placed the files.

> Rob Blimploid wrote:
>> application.html.erb is correctly finding the stylesheet for my project
>> via <%= stylesheet_link_tag 'style1' %>.  My webpages reflect the
>> styling properly with a few exceptions .. the most notable being some
>> .jpg images defined for background do not display at all.  I have those
>> images in public/images.
>>
>>
>
> So, the URL for the images is images/... relative to the path of your
> application.
>
>> The following is the stylesheet code containing the reference to the
>> image.
>>
>> #navigation {
>>   width: 180px;
>>   height: 484px;
>>   background: #7da5a8 url(backgrounds/nav-bg.jpg) no-repeat;
>> }
> If your stylesheet is in public/stylesheets/styles.css [example], then
> the relative path to the images directory is:
> url(../images/...jpg) or url(../images/backgrounds/image.jpg)
> depending on where exactly you placed the files.
>
> Cheers,
> Mohit.
> 4/16/2009 | 12:30 AM.

Many thanks Mohit ... worked beautifully using the relative path !!
Didn't expect such a quick response with the correct solution !!

Cheers to you as well !
34a7615f38496a5dafbb3e6b721c435e?d=identicon&s=25 Mohit Sindhwani (Guest)
on 2009-04-15 18:58
(Received via mailing list)
Rob Blimploid wrote:
> Many thanks Mohit ... worked beautifully using the relative path !!
> Didn't expect such a quick response with the correct solution !!
>
> Cheers to you as well !
>

You're most welcome.  I'm not replying for you, it's a selfish move - I
just asked a question myself, so I'm waiting for answers :P
This is me paying it forward :)

Cheers,
Mohit.
4/16/2009 | 12:57 AM.
This topic is locked and can not be replied to.