Re: CSS background images
Re: CSS background images
- Subject: Re: CSS background images
- From: A <email@hidden>
- Date: Wed, 13 Aug 2008 09:49:19 -0400
Thanks,
I should mention that I'm developing under Windows, using Eclipse and WOLips.
I viewed the source of the CSS file that I used that worked, and it
had generated a URL like this:
/cgi-bin/WebObjects/WebApp.woa/wr?wodata=file:/C:/Apple/workspace/WebApp/build/WebApp.woa/Contents/WebServerResources/Images/img_00.gif
Taking away the CSS component and inserting that URL into the original
CSS file made the image show up (of course), and so I went about
trying to enter relative URLs with no success.
>From my knowledge, if a stylesheet is sitting as
/WebServerResources/Styles/style.css, then a declaration to access an
image located at /WebServerResources/Images/img_00.gif should be able
to access that image as ../Images/img_00.gif (up one directory to
/WebServerResources, into /WebServerResources/Images)
I tried a few others, though they were mainly blind stabs. It seems to
me that ../Images/imgname should work.
Can you suggest a proper relative URL to use for that directory structure?
All the best
On Wed, Aug 13, 2008 at 9:13 AM, Denis Frolov <email@hidden> wrote:
> Hi,
>
> On Wed, Aug 13, 2008 at 5:03 PM, A <email@hidden> wrote:
>> Hey,
>>
>> I've been designing a layout with static html/css that I'm now trying
>> to add dynamic elements to via webobjects. I added the stylesheet to
>> WebServerResources/styles and the images to WebServerResources/images.
>>
>> In the stylesheet, I tried declarations like
>> background-image: url('../images/img_00.gif');
>> which should pull up the image for the directory structure I specified.
>
> Relative urls in css should work - we use this approach for all our
> projects. Open Activity window in Safari to debug the url to image
> that doesn't work. You should see semething like:
>
> http://localhost/cgi-bin/WebObjects/MyApp.woa/-41424/wr/wodata=/Users/user/Documents/workspace/MyApp/build/MyApp.woa/Contents/WebServerResources/images/logo.gif
>
> Check this url in Finder to see why it fails.
>
>>
>> It didn't work, so I tried a few other relative urls, a few absolute
>> urls, and never got the images to show.
>>
>> I decided I would use the WOResourceURL component to get at the
>> images, so I created a WO component with declarations like:
>> background-image: url('<wo name="Img00"/>');
>>
>> and the WOD file would say something like:
>> Img00 : WOResourceURL { filename = "WebServerResources/Images/img_00.gif"; }
>>
>> I felt a little dirty doing this, since I would really rather have the
>> stylesheet defined as a CSS file that the browser can easily cache
>> rather than a WO component which bloats the generated mark up of every
>> page in the app.
>>
>> There is an even bigger problem however, that each page now loads very
>> slowly. It seems to me that all of the images are being reloaded on
>> every request, which is making it painful to develop.
>>
>> So on to my questions:
>>
>> What is the best way to reference a stylesheet with images?
>>
>> If I use the approach I outlined, will the deployed app cache the CSS
>> component and images so that they don't slow down the app?
>>
>> If so, is there something I can do in development to display the
>> images but force them not to reload on every request?
>>
>>
>> Thank you!
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden