7 replies [Last post]
ocean
ocean's picture
Offline
newbie
Last seen: 17 years 21 weeks ago
Joined: 2003-12-19
Posts: 4
Points: 0

i try to use css in my website's templates
i inserted the following statement under <head> in the template file
<link rel="stylesheet" type="text/css" href="home.css">

however, it is not work when preview

the css file is

<style>
#banner {background: url(../image/topbannerhome.gif) no-repeat }
</style>

If i inserted the following statements under <head> in the template file

<style type="text/css">
#banner {background: url(../image/topbannerhome.gif) no-repeat }
</style>

then it is work

Can anyone help me to solve this problem?
i want to use css files in the templates
what should i do?
THANK YOU VERY MUCH

dJomp
dJomp's picture
Offline
Enthusiast
Last seen: 5 years 14 weeks ago
Joined: 2003-03-23
Posts: 422
Points: 0

Using CSS in templates

Yep!

The CSS file should not have HTML tags in it.

Remove the <style> and </style> and all should work.

You know you're a geek when you try to shoo a fly away from the monitor with your cursor.

ocean
ocean's picture
Offline
newbie
Last seen: 17 years 21 weeks ago
Joined: 2003-12-19
Posts: 4
Points: 0

Using CSS in templates

i rewrited the css file to just only have the statement

#banner {background: url(../image/topbannerhome.gif) no-repeat }

but it still doesn't work

is there any problem of my codes?

ocean
ocean's picture
Offline
newbie
Last seen: 17 years 21 weeks ago
Joined: 2003-12-19
Posts: 4
Points: 0

Using CSS in templates

i put all the templates in a folder called Templates which is in the root folder
ie. ../root/Templates/home.dwt

but the css file is in the root folder not in the Templates folder
ie. ../root/home.css

and the home.jsp which use the home.dwt templates and the home.css is also in the root folder
ie. ../root/home.jsp

is there any problem?
the coding is the same as the above post

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 1 day ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

Using CSS in templates

Hi ocean,
It could be the path to your background image.
Is the image directory at the same level as root ?

Hope that helps

ocean
ocean's picture
Offline
newbie
Last seen: 17 years 21 weeks ago
Joined: 2003-12-19
Posts: 4
Points: 0

Using CSS in templates

The path of the image is correct

because i have inserted the whole css code in the jsp file

<style type="text/css"> 
#banner {background: url(../image/topbannerhome.gif) no-repeat } 
</style>

the image can be displayed

however, if i use css file, then it can't be displayed

is there any problem with my jsp file?

i copy the coding of the head of jsp file

<html>
<head>
<title> Home</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<link rel="stylesheet" type="text/css" href="../css/home.css">

<script language="JavaScript" type="text/JavaScript">

Thank you very much

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 1 day ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

Using CSS in templates

Hi ocean,
It's possible your server hasn't got the mime type for CSS set up.
If the server is local do a search on google to find out how to add mime types for your server type.

Hope that helps

puiwaihin
Offline
newbie
Last seen: 17 years 19 weeks ago
Joined: 2004-01-01
Posts: 1
Points: 0

where are you linking from?

Are you typing the code directly into the template, or are you using DW to link to the CSS? Try deleting the link code then go "Text/CSS Styles" and choose "Attach Style Sheet" rather than typing the code in directly. Then save your template and see if the problem goes away.

Sometimes when you type the code in yourself DW doesn't update the pages correctly.