I need a little help with this (<!-- m --><a class="postlink" href="http://host191.ipowerweb.com/~minglewi/taylor2/">http://host191.ipowerweb.com/~minglewi/taylor2/</a><!-- m -->) page. As you can see, its looking moderately decent in firefox, but once you unleash the beast on it, it gets butchered entirely. Any idea what's happening?Well... that certainly looks... unique. Kinda cool though...
I think that your problem might be similiar to Paul Jr.'s (<!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/showthread.php?s=&threadid=40652">http://www.webdeveloper.com/forum/showt ... adid=40652</a><!-- m -->)... the only real issue is the left sidebar being pushed down. Everything else looks right once the pix load.OK, Got it working now. It was 1px too much margin in IE. Thank you !important. Anyways, feel free to tear it apart here (<!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/showthread.php?s=&threadid=40679">http://www.webdeveloper.com/forum/showt ... adid=40679</a><!-- m -->)For the record, If you want to keep your code a little bit cleaner, use
html>body #foo {actual browser rules}
#foo {IE rules}
since there's more selectors in the first rule, it shouldn't matter the order they come in.but i only needed 1 hack, so i think its a few bytes lighter to use !importantI was only saying it to cover the bases.Originally posted by omega
For the record, If you want to keep your code a little bit cleaner, use …
Actually, I would user PHP to sniff for individual browsers and serve up the appropriate CSS rules (which is actually what I do now ).Okay... so instead of loading a few more bytes, you add more work for the server, and a longer wait so the script writing the PHP can be executed...?Originally posted by omega
Okay... so instead of loading a few more bytes, you add more work for the server
Geez, it’s just a little browser niffing, you act like I’m running a forum or something.
Originally posted by omega
and a longer wait so the script writing the PHP can be executed...?
It doesn’t take any longer.
And I’m efficiently using server-side coding to eliminate bloated and unnecessary hacks from my CSS file and generally making things easier on me. Plus, as someone said in a comment at mezzoblue, relying on browser quirks is not always 100% reliable.It was a few weeks after I started using css for the first time that I actually looked at my pages in IE. I've used browser detection in one form or another ever since.Paul- I was just kidding, calm your hormones (Still J/k)... I would probably do the same if it didn't require header()...Why can't/won't you use header() ?Lack of header functions due to slightly retarded server... it has no problem when xBlogLite uses 'em, but if I use 'em, a nice little error, even in pages like <?php header("Location: <!-- m --><a class="postlink" href="http://www.google.com/">http://www.google.com/</a><!-- m -->"); ?> <sigh />Paul would you care to share how you use PHP to send different values to different browsers.If it's box model problems you're having then there's no need for any hacks. Use one div for the width and nest another inside with padding, and so on.But that adds unncessary markup. Originally posted by omega
Lack of header functions due to slightly retarded server... it has no problem when xBlogLite uses 'em, but if I use 'em, a nice little error, even in pages like <?php header("Location: <!-- m --><a class="postlink" href="http://www.google.com/">http://www.google.com/</a><!-- m -->"); ?> <sigh />
If one program can use 'em, the YOUR JUST SCREWING IT UP! Face facts man, you hopeless. You'll never make it in this world. It's not your fault, you didn't want to be this way, but you are.
j/k. Really. What? Oh, you don't believe me?
I had issues with headers before, and then I realized I was getting issues because you aren't allowed to output anything before a header. No includes (less theres no outputted info in em) no echos, cookies can even cause issues. just a header, nothing else goes out before it, because it's the HEAD. Like what's supposed to be atop your shoulders. Heh. I figured it out, actually. Encoding has to be ANSI, instead of UTF-8. That's all it was.
Makes you wanna kill things, don't it...?Originally posted by sharkey
Paul would you care to share how you use PHP to send different values to different browsers.
I have this nifty little script (well, just a few if statements) for sniffing our browsers that I use in just about every one of my CSS files. It’s on my computer, so I won’t be able to get it to you until tomorrow.But doesn't PHP return the default browser? Like if someone's default browser was Internet Explorer, but they were using Opera, than they would get the IE stylesheet. I'd just rather make one cross browser style sheet.I have Fire Fox as my default browser, but the script (if you can call it that) in my signature still works on the other browsers I test with.
As for a single style sheet. Well, like I said, I just suck. I can never convince IE to display the same as a browser would no matter what I try.
I guess I'll get the swing of it some time.Oh, I see now. However, your signature script doesn't work! You should be checking whats after the paranthesis (sp?) Because I get your angry message when viewing in Opera. But I guess the first bit is your default browser or something, because it keeps saying Mozilla. erg, whatever.It’s quite simple; only sniffs out Moz, IE, and Opera.
This goes at the top of almost all of my CSS files:
<?php
header('content-type: text/css');
$browser = $_SERVER['HTTP_USER_AGENT'];
$opera = (stristr($browser, 'Opera') !== false) && (stristr($browser, 'MSIE') === false);
$ie = (stristr($browser, 'Opera') === false) && (stristr($browser, 'MSIE') !== false);
$moz = (stristr($browser, 'Mozilla') !== false) && (stristr($browser, 'MSIE') === false);
?>
That’s it. It has worked for me thus far, so…Actually, to properly detect Opera, it needs to be:
<?php
header('content-type: text/css');
$browser = $_SERVER['HTTP_USER_AGENT'];
$opera = (stristr($browser, 'Opera') !== false) && (stristr($browser, 'MSIE') !== false);
$ie = (stristr($browser, 'Opera') === false) && (stristr($browser, 'MSIE') !== false);
$moz = (stristr($browser, 'Mozilla') !== false) && (stristr($browser, 'MSIE') === false);
?>
Because Opera gives, for me at least, this header:
Mozilla/4.0 (compatible; MSIE 6.0; Windows ME) Opera 7.50 [en]That will only catch Opera when it is spoofing as IE. I made a little booboo up there. Simple revision, and it will catch Opera spoofing or not.
<?php
header('content-type: text/css');
$browser = $_SERVER['HTTP_USER_AGENT'];
$opera = (stristr($browser, 'Opera') !== false);
$ie = (stristr($browser, 'Opera') === false) && (stristr($browser, 'MSIE') !== false);
$moz = (stristr($browser, 'Mozilla') !== false) && (stristr($browser, 'MSIE') === false);
?>
If you look, you’ll notice I just removed this part:
&& (stristr($browser, 'MSIE') === false)
Anyhoo, sorry, my bad. Thanks paul i lost this thread and couldnt find it for a while but thanks for showing me your script my one last question how do you now get it to say well give IE a margin on the body of 20px and in mozilla 10px just an example.
Thanks again mate.I use <?php
echo <link rel=\\\"stylesheet\" href=http://www.webdeveloper.com/forum/archive/index.php/\"wherever.css\" type=\"text/css\">
(note the syntax error immediately following rel=. I can't seem to escape a "\" in.)
Most of the time as I usually have to dish out completely seperate css files because of the mess it makes of the whole file.
However if it's only one thing that needs changing then you may as well just add your style sheet as notmal just using xhtml but with the style definition you want altering omitted from your css file. Then in the head just use
<style type="text/css">
<?php
sinffoutbrowser()
if (browser is IE)
{style:definition1; /* for IE */}
else
{style:definition2; /* for web browsers */}
?>
</style>
That way the single style definition just buts in where required and supplements the linked css file.Cheers mr herer just what i needed.
Thanks again
Chris SharkeyOriginally posted by sharkey
Thanks paul i lost this thread and couldnt find it for a while but thanks for showing me your script my one last question how do you now get it to say well give IE a margin on the body of 20px and in mozilla 10px just an example.
Thanks again mate.
As Mr. Herer said, something along the lines of this:
body {
<?php if($ie) { ?>
margin: 20px;
<?php } else { ?>
margin: 10px;
<?php } ?>
}I plonked something like that in a page I made the other day. A number is called from a database and thrown into a single style definition for the height of a div. like:<style type="text/css">
.changingdiv {
height:<?php echo $numberfromdbase; ?>;
</style>
This very simple, single style definition is used in conjunction with a full sized style sheet called via <link>. Then I just use a simple form I made elsewhere on the site to change and store the number in the database. That way I can alter the height of the div in a flash with no massing with the code directly.
I've actually done quite a lot more like this (and will continue to do so) for the site I'm making. I'm just doing stuff like this to learn php. Just thought I'd give ya a quick example of some of the css/php type stuff I've been tinkering with. Wow, that's laziness... ... I might work out a script to allow editing of each setting, that writes to the CSS file. It'll take a long ass time, but I might do it, someday. ^_^
I think that your problem might be similiar to Paul Jr.'s (<!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/showthread.php?s=&threadid=40652">http://www.webdeveloper.com/forum/showt ... adid=40652</a><!-- m -->)... the only real issue is the left sidebar being pushed down. Everything else looks right once the pix load.OK, Got it working now. It was 1px too much margin in IE. Thank you !important. Anyways, feel free to tear it apart here (<!-- m --><a class="postlink" href="http://www.webdeveloper.com/forum/showthread.php?s=&threadid=40679">http://www.webdeveloper.com/forum/showt ... adid=40679</a><!-- m -->)For the record, If you want to keep your code a little bit cleaner, use
html>body #foo {actual browser rules}
#foo {IE rules}
since there's more selectors in the first rule, it shouldn't matter the order they come in.but i only needed 1 hack, so i think its a few bytes lighter to use !importantI was only saying it to cover the bases.Originally posted by omega
For the record, If you want to keep your code a little bit cleaner, use …
Actually, I would user PHP to sniff for individual browsers and serve up the appropriate CSS rules (which is actually what I do now ).Okay... so instead of loading a few more bytes, you add more work for the server, and a longer wait so the script writing the PHP can be executed...?Originally posted by omega
Okay... so instead of loading a few more bytes, you add more work for the server
Geez, it’s just a little browser niffing, you act like I’m running a forum or something.
Originally posted by omega
and a longer wait so the script writing the PHP can be executed...?
It doesn’t take any longer.
And I’m efficiently using server-side coding to eliminate bloated and unnecessary hacks from my CSS file and generally making things easier on me. Plus, as someone said in a comment at mezzoblue, relying on browser quirks is not always 100% reliable.It was a few weeks after I started using css for the first time that I actually looked at my pages in IE. I've used browser detection in one form or another ever since.Paul- I was just kidding, calm your hormones (Still J/k)... I would probably do the same if it didn't require header()...Why can't/won't you use header() ?Lack of header functions due to slightly retarded server... it has no problem when xBlogLite uses 'em, but if I use 'em, a nice little error, even in pages like <?php header("Location: <!-- m --><a class="postlink" href="http://www.google.com/">http://www.google.com/</a><!-- m -->"); ?> <sigh />Paul would you care to share how you use PHP to send different values to different browsers.If it's box model problems you're having then there's no need for any hacks. Use one div for the width and nest another inside with padding, and so on.But that adds unncessary markup. Originally posted by omega
Lack of header functions due to slightly retarded server... it has no problem when xBlogLite uses 'em, but if I use 'em, a nice little error, even in pages like <?php header("Location: <!-- m --><a class="postlink" href="http://www.google.com/">http://www.google.com/</a><!-- m -->"); ?> <sigh />
If one program can use 'em, the YOUR JUST SCREWING IT UP! Face facts man, you hopeless. You'll never make it in this world. It's not your fault, you didn't want to be this way, but you are.
j/k. Really. What? Oh, you don't believe me?
I had issues with headers before, and then I realized I was getting issues because you aren't allowed to output anything before a header. No includes (less theres no outputted info in em) no echos, cookies can even cause issues. just a header, nothing else goes out before it, because it's the HEAD. Like what's supposed to be atop your shoulders. Heh. I figured it out, actually. Encoding has to be ANSI, instead of UTF-8. That's all it was.
Makes you wanna kill things, don't it...?Originally posted by sharkey
Paul would you care to share how you use PHP to send different values to different browsers.
I have this nifty little script (well, just a few if statements) for sniffing our browsers that I use in just about every one of my CSS files. It’s on my computer, so I won’t be able to get it to you until tomorrow.But doesn't PHP return the default browser? Like if someone's default browser was Internet Explorer, but they were using Opera, than they would get the IE stylesheet. I'd just rather make one cross browser style sheet.I have Fire Fox as my default browser, but the script (if you can call it that) in my signature still works on the other browsers I test with.
As for a single style sheet. Well, like I said, I just suck. I can never convince IE to display the same as a browser would no matter what I try.
I guess I'll get the swing of it some time.Oh, I see now. However, your signature script doesn't work! You should be checking whats after the paranthesis (sp?) Because I get your angry message when viewing in Opera. But I guess the first bit is your default browser or something, because it keeps saying Mozilla. erg, whatever.It’s quite simple; only sniffs out Moz, IE, and Opera.
This goes at the top of almost all of my CSS files:
<?php
header('content-type: text/css');
$browser = $_SERVER['HTTP_USER_AGENT'];
$opera = (stristr($browser, 'Opera') !== false) && (stristr($browser, 'MSIE') === false);
$ie = (stristr($browser, 'Opera') === false) && (stristr($browser, 'MSIE') !== false);
$moz = (stristr($browser, 'Mozilla') !== false) && (stristr($browser, 'MSIE') === false);
?>
That’s it. It has worked for me thus far, so…Actually, to properly detect Opera, it needs to be:
<?php
header('content-type: text/css');
$browser = $_SERVER['HTTP_USER_AGENT'];
$opera = (stristr($browser, 'Opera') !== false) && (stristr($browser, 'MSIE') !== false);
$ie = (stristr($browser, 'Opera') === false) && (stristr($browser, 'MSIE') !== false);
$moz = (stristr($browser, 'Mozilla') !== false) && (stristr($browser, 'MSIE') === false);
?>
Because Opera gives, for me at least, this header:
Mozilla/4.0 (compatible; MSIE 6.0; Windows ME) Opera 7.50 [en]That will only catch Opera when it is spoofing as IE. I made a little booboo up there. Simple revision, and it will catch Opera spoofing or not.
<?php
header('content-type: text/css');
$browser = $_SERVER['HTTP_USER_AGENT'];
$opera = (stristr($browser, 'Opera') !== false);
$ie = (stristr($browser, 'Opera') === false) && (stristr($browser, 'MSIE') !== false);
$moz = (stristr($browser, 'Mozilla') !== false) && (stristr($browser, 'MSIE') === false);
?>
If you look, you’ll notice I just removed this part:
&& (stristr($browser, 'MSIE') === false)
Anyhoo, sorry, my bad. Thanks paul i lost this thread and couldnt find it for a while but thanks for showing me your script my one last question how do you now get it to say well give IE a margin on the body of 20px and in mozilla 10px just an example.
Thanks again mate.I use <?php
echo <link rel=\\\"stylesheet\" href=http://www.webdeveloper.com/forum/archive/index.php/\"wherever.css\" type=\"text/css\">
(note the syntax error immediately following rel=. I can't seem to escape a "\" in.)
Most of the time as I usually have to dish out completely seperate css files because of the mess it makes of the whole file.
However if it's only one thing that needs changing then you may as well just add your style sheet as notmal just using xhtml but with the style definition you want altering omitted from your css file. Then in the head just use
<style type="text/css">
<?php
sinffoutbrowser()
if (browser is IE)
{style:definition1; /* for IE */}
else
{style:definition2; /* for web browsers */}
?>
</style>
That way the single style definition just buts in where required and supplements the linked css file.Cheers mr herer just what i needed.
Thanks again
Chris SharkeyOriginally posted by sharkey
Thanks paul i lost this thread and couldnt find it for a while but thanks for showing me your script my one last question how do you now get it to say well give IE a margin on the body of 20px and in mozilla 10px just an example.
Thanks again mate.
As Mr. Herer said, something along the lines of this:
body {
<?php if($ie) { ?>
margin: 20px;
<?php } else { ?>
margin: 10px;
<?php } ?>
}I plonked something like that in a page I made the other day. A number is called from a database and thrown into a single style definition for the height of a div. like:<style type="text/css">
.changingdiv {
height:<?php echo $numberfromdbase; ?>;
</style>
This very simple, single style definition is used in conjunction with a full sized style sheet called via <link>. Then I just use a simple form I made elsewhere on the site to change and store the number in the database. That way I can alter the height of the div in a flash with no massing with the code directly.
I've actually done quite a lot more like this (and will continue to do so) for the site I'm making. I'm just doing stuff like this to learn php. Just thought I'd give ya a quick example of some of the css/php type stuff I've been tinkering with. Wow, that's laziness... ... I might work out a script to allow editing of each setting, that writes to the CSS file. It'll take a long ass time, but I might do it, someday. ^_^