Forum Moderators: not2easy

Message Too Old, No Replies

css and Mozilla not working, need help

though IE and Opera work fine

         

AMD_user

5:24 am on Jul 30, 2005 (gmt 0)

10+ Year Member



I have this strange problem with my apache2 web-server. The pages looks good in MSIE and Opera but Mozilla does not read the css file. I found this error message in Mozilla

Error: The stylesheet http://www.example.myphotos.cc/style.php was not loaded because its MIME type, "text/html", is not "text/css".

[edited by: jatar_k at 5:27 am (utc) on July 30, 2005]
[edit reason] generalized url [/edit]

jatar_k

5:34 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld AMD_user,

you might want to take a look at this thread
PHP in CSS files [webmasterworld.com]

AMD_user

6:03 am on Jul 30, 2005 (gmt 0)

10+ Year Member



Thank you for quick answer. Tried adding .htaccess and

AddType application/x-httpd-php .htm .css

in Vhosts file, and still have the same problem in Mozilla.

jatar_k

6:08 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I noticed the css file has a php extension, I was more wondering whether you might need the proper content type header to be output

such as
header('Content-Type: text/css');

in the top of your css file

AMD_user

6:14 am on Jul 30, 2005 (gmt 0)

10+ Year Member



When I add
<? Header ("Content-type: text/css");?>
t othe top of the php file the page looks worse in MSIE and Opera, and still not working in Mozilla.
Is it possible to upload commonhttp.conf and style.php to this forum? Maybe I have done some stupid mistake

I've tried to fix this for 2 days now ....

jatar_k

6:16 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hmmm

what if you add the AddType line and then switch the extension of your css to .css instead of php?

AMD_user

6:19 am on Jul 30, 2005 (gmt 0)

10+ Year Member



Sorry, I'm not that good. Please tell me how to do this ...

AMD_user

6:23 am on Jul 30, 2005 (gmt 0)

10+ Year Member



Tried it, no change ...

jatar_k

6:25 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what does your css file look like?

AMD_user

6:26 am on Jul 30, 2005 (gmt 0)

10+ Year Member



<? Header ("Content-type: text/css");?>

body
{
font-family: verdana, Verdana, Helvetica, courier, serif; background-color:#EBEBEB;
color:yellow; font-size: 13px; background-image: url('bakgrunn.jpg');
background-attachment: fixed; margin-top: 1px
}

div#main{
width:900px;
margin-left:auto;
margin-right:auto;
}

div#content{
float:right;
display:block;
width:700px;
height:400px;
margin-top: -400px;
}

div#header{
display:block;
position: static;
width:900px;
height:100px;
background-image: <?
$link="http://example.no/arnbir/index.html";
function checklink($link)
{
//see if we have a link to check
if($link)
{
//open the url
$file = @fopen ("$link", "r");
}
if($file)
{ return true ;
fclose($file);
}
}
if($link!="")
{
//show result if good
if((checklink($link))=="true")
{
echo "url('http://example.no/arnbir/baktop.jpg')";
}
else
{
//show result if bad
echo "url('http://www.example.org/baktop.jpg')" ;
}
}
?>;
background-repeat: repeat;
font-size: 3em;
}

div#footer{
display: block;
position: static;
width: 900px;
height: 100px;
background-image:<?
{
//show result if good
if((checklink($link))=="true")
{
echo "url('http://example.no/arnbir/bunn.jpg')";
}
else
{
//show result if bad
echo "url('http://www.example.dyndns.org/bunn.jpg')" ;
}
}
?>;
background-repeat: no-repeat;
}

div#footer2{
display: block;
position: static;
margin-top: -40px;
margin-left:auto;
margin-right:auto;
width: 30px;
height: 30px;
}

div#headermeny {
display: block;
margin-left:auto;
margin-right:auto;
float: right;
margin-top: -20px;
position: static;
width: 700px;
height: 20px;
color: white;
font-size: 8;
/*background-image: url('test.png');*/

}

div#gradient {
display: block;
position: static;
width: 200px;
/*margin-top: -400px;*/
height: 200px;
background-image:<?
{
//show result if good
if((checklink($link))=="true")
{
echo "url('http://example.no/arnbir/bakmidopp.jpg')";
}
else
{
//show result if bad
echo "url('http://www.example.org/bakmidopp.jpg')" ;
}
}
?>;
background-repeat: repeat;
}
div#gradient2 {
display: block;
position: static;
width: 200px;
/*margin-top: -400px;*/
height: 200px;
background-image:<?
{
//show result if good
if((checklink($link))=="true")
{
echo "url('http://example.no/arnbir/bakmidopp.jpg')";
}
else
{
//show result if bad
echo "url('http://www.example.org/bakmidopp.jpg')" ;
}
}
?>;
background-repeat: repeat;
}

a{ color: #FCFCFC; font-weight: bold; font-size: 13px; }
a:visited { color: #FEE404; font-weight: bold; font-size: 13px; }
a:hover { color: #000000; font-weight: bold; font-size: 13px; }
a:active { color: #990000; font-weight: bold; font-size: 13px; }

div#meny3{
width: 150px;
display: block;
margin-left: auto;
margin-right: auto;
/*background: yellow;*/
color: yellow;
font-size: 11px;

}

div#meny {
width: 150px;
display: block;
margin-left: auto;
margin-right: auto;
/*background: yellow;*/
color: black;
font-size: 13px;

}
div#kontakt{
width: 150px;
display: block;
margin-left: auto;
margin-right: auto;
/*background: yellow;*/
color: white;
font-size: 13px;
font-weight: bold;
}

ul{margin-top: 0px;}
li{
margin-left: -40px;
list-style: none;
}
div#menytop
{
display: block;
width: 150px;
margin-left: auto;
margin-right: auto;
margin-top:10px;
background: black;
color: yellow;
font-weight: bold;
font-size: 13px;
}

div#menytop p {
font-weight: bold;
text-align: center;
margin-bottom: 0pt;
}

[edited by: jatar_k at 6:28 am (utc) on July 30, 2005]
[edit reason] removed urls [/edit]

jatar_k

6:44 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



how about this, hehe

try changing this line

<div id="header"></div>

to

<div id="header">&nbsp;</div>

AMD_user

6:48 am on Jul 30, 2005 (gmt 0)

10+ Year Member



in the index - file?

jatar_k

6:49 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



in the html, yes

AMD_user

6:50 am on Jul 30, 2005 (gmt 0)

10+ Year Member



Tried it, no change

jatar_k

6:59 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



when I use this [exact] html, since I have this setup for testing, it works

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="no" xml:lang="no" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<title>Web-design og PC-reparasjon </title>
<link rel="stylesheet" type="text/css" href="style.php" />
</head>
<body>
<div align="center">
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="900" height="25"></td>
</tr>
<tr>
<td>
<div id="header">&nbsp;</div>
</td>
</tr>
</table>
</div>
<div align="center">
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="900" height="38">
<div id="meny">
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="500" height="38"></td>
<td width="200" height="38">galleri</td>
<td width="200" height="38">Om Meg</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<div align="center">
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div id="hoved"></div>
</td>
</tr>
</table>
</div>
</body>
</html>

jatar_k

7:02 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the menu position is a little funky but it gets the background image and I used the stylesheet you posted

AMD_user

7:05 am on Jul 30, 2005 (gmt 0)

10+ Year Member



I hvae tried it on a different web-page. I only have a ADSL connection and to save bandwith I reely need to get this script to work inside css

<?
$link="http://example.no/arnbir/index.html";
function checklink($link)
{
//see if we have a link to check
if($link)
{
//open the url
$file = @fopen ("$link", "r");
}
if($file)
{ return true ;
fclose($file);
}
}
if($link!="")
{
//show result if good
if((checklink($link))=="true")
{
echo "url('http://example.no/arnbir/baktop.jpg')";
}
else
{
//show result if bad
echo "url('http://www.example.org/baktop.jpg')" ;
}
}
?>;

I allways let my customers view the pages on my server before uploading to the web.

Can i send you a pm with the url I have been testing this on?

jatar_k

7:12 am on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I really think the problem is in the CSS or the HTML, I think php and apache are incidental.

I got it to work just adding the &nbsp; to the header div.

sorry have to go to bed, it's late and I have to go pick up my daughter early, I feel really badly leaving you hanging but there are more than enough competent folk around to lend a hand.

AMD_user

7:14 am on Jul 30, 2005 (gmt 0)

10+ Year Member



Thanks alot for your help....

jatar_k

2:36 pm on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



did you figure it out yet?

AMD_user

3:18 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



nope, been busy working on the new page ...

jatar_k

3:19 pm on Jul 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



anyone else have any ideas other than my lame attempts?
any explanations?

AMD_user

3:28 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



Is it possible to copy the content of the php-file in to the header section of the html just to test?

AMD_user

3:43 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



This is embarresing ..
adding <?php header("Content-Type: text/css; encoding=UTF-8");?> in the top of the php-file did the trick. I lissed the encoding=UTF-8"); when i tried...

AMD_user

3:50 pm on Jul 30, 2005 (gmt 0)

10+ Year Member



Thank you so much for your time and efforts :-)