I'm new to CSS and interested in the example codes shown here. Problem is, at least for some of the CSS examples, while they work just fine if I cut-and-paste the CSS code between <style></style> tags in the HTML header, they don't seem to work so well when I save the CSS code into an external .css file.
For instance, CSS square buttons. If I paste the CSS code verbatim into the provided HTML, slap some DTD and <body></body> tags, etc., on, it works just fine (screenshot).
If I instead paste the given code unchanged into a tabs.css file, and drop:
into the HTML header in place of the CSS code, I get garbage (screenshot). Note that the only change I make is replacing <style type="text/css">CSSpastedfrompage</style> with the line above.Code:<link rel=stylesheet type="text/css" href="tabs.css" />
I'm using Firefox, Fedora 9, and XAMPP for Linux to run the Apache web server. I've just dropped both the test HTML files and the CSS files I refer to straight into the web root directory, for simplicity, though I have created a "media" subdirectory to hold the .gif images. I've even changed XAMPP/Apache's httpd.conf file to contain an explicit "AddType text/css .css" statement in case that was the problem.
Clearly the problem isn't that CSS files can't be served at all -- in the "Fail" case, where I try to use external CSS, it is still somehow finding the right-hand portions of the buttons, but it isn't resizing them and is missing the left-hand portions altogether.
Interestingly, I have a similar problem with vertical wire frame menus (when I drop the CSS into the test HTML directly, it renders just like the example page, but when I try to refer to it as an external CSS file I get wire frames that extend the width of the browser instead), but the animated horizontal tabs seem to work fine as an external CSS file.
I'm excited when I see the CSS working, but I'd really like to use these styles to help design an entire site, not just a single page, and I kind of thought that was the point -- being able to dump all your style/presentation information into a separate page and focus the HTML pretty much on content.
For reference, the complete HTML I'm using to reference the "button.css" (itself an exact unaltered paste of the Square Button CSS code) is:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Fail</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel=stylesheet type="text/css" href="button.css" /> </head> <body> <h4>Single button:</h4> <div class="buttonwrapper"> <a class="squarebutton" href="http://www.dynamicdrive.com/style/"><span>Dynamic Drive CSS Library</span></a> </div> <h4>Side by Side:</h4> <div class="buttonwrapper"> <a class="squarebutton" href="#"><span>Submit</span></a> <a class="squarebutton" href="#" style="margin-left: 6px"><span>Reset</span></a> </div> </body> </html>



Reply With Quote



Bookmarks