[web] CSS is pi***ng me off!
#1 Members - Reputation: 102
Posted 30 March 2011 - 02:44 PM
Coming from a C++ background, HTML and CSS are a bit of a black-art. It's all very "well you want the right-aligned, but on some browsers it might be a bit more to the left".
I spend ages trying to get my HTML page to do what I want in Chrome, gave up, then tried IE and it renders fine!! So WTF is Chrome doing differently?
The "Inspect Element" tool in Chrome is pretty useful, but I'm still struggling A LOT with all this stuff.
HELP!
ps. Any advice on tools or methods to improve my CSS authoring?
#2 GDNet+ - Reputation: 1883
Posted 30 March 2011 - 04:58 PM
Most modern browsers are pretty consistent as long as you are in standards mode. In quirks mode, just about anything goes...
#3 Staff - Reputation: 9017
Posted 30 March 2011 - 05:01 PM
2. Use good editing tools. There generally isn't all that much to a css file visually even when it gets complicated, but you should still be using a well-featured editor you're comfortable with. Features you might want to look for include syntax highlighting, auto-completion, the ability to "collapse" or "fold" sections of the document away, and a good find-and-replace feature.
3. Use good browser tools. The tools in Chrome that you're already aware of are quite good. The FireBug extension for FireFox is another excellent example.
- Jason Astle-Adams.
From my blog: 20 ways to advertise your game | What next? Intermediate to advanced C++
How to make games WITHOUT programming | 4 reasons you aren't a successful indie developer
#5 Members - Reputation: 136
Posted 31 March 2011 - 08:21 AM
Chrome tools and Firebug are already mentioned, for "easy CSS" you may try the likes of Stylizer - you can download the trial and see if it's good for you.
***[[[And basically, educate yourself for a start - you'll then notice that markup is more than 'copy'n'pasta of some template' - each element has it's purpose, you'll learn about doctypes, microdata, semantics, why it's good for you to have an alt tag even if you're not bothered about accessibility (or why by creating an all-flash website you're hurting yourself). You'd eventually get to know CSS better, the browsers and what to expect out of them, etc etc. Google around, you can check those 2 for some reading: htmldog , A list apart . If you get to streamlining your work have a look at 960gs and HTML5 boilerplate. Avoid w3schools and THIS is why;)]]]
*** - 99.99999% not relevant as you seem to just want to 'get your site sorted quickly & easily' rather than becoming a top-notch frontend dev.
Hope any of this helps;)
#6 Members - Reputation: 539
Posted 31 March 2011 - 09:59 AM
#7 Members - Reputation: 172
Posted 05 April 2011 - 07:53 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">That will force all IE browsers to render using a strict adherence to the W3 rules, or at least an attempt at strict adherence.
Second, get a really good understanding of the box model and CSS hierarchy, which is probably the most mis-understood part of HTML development. Most people don't realize that you can apply multiple styles to the same HTML element. For example:
<div class="ContentPane FloatingLeft">This is my content</div>This HTML applies 2 styles to the DIV, ContentPane and FloatingLeft.
Third, sometimes it helps to force all the HTML elements to a common set of rules so that all styles are set to a common set of features that would be applied in all browsers.
But to really help, some HTML examples would be nice.
Good judgment is gained through experience. Experience, however, is gained through bad judgment.
Visit http://ajaxmud.net for information about developing web-based games
#8 Members - Reputation: 102
Posted 06 April 2011 - 10:28 AM
I can help out, but you have to let me know what are you trying to accomplish. I can tell you that IE will make it difficult to get things looking right, especially in quirks mode. First thing, add to top of all your documents the following line (before the <html /> tags) :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">That will force all IE browsers to render using a strict adherence to the W3 rules, or at least an attempt at strict adherence.
Second, get a really good understanding of the box model and CSS hierarchy, which is probably the most mis-understood part of HTML development. Most people don't realize that you can apply multiple styles to the same HTML element. For example:<div class="ContentPane FloatingLeft">This is my content</div>This HTML applies 2 styles to the DIV, ContentPane and FloatingLeft.
Third, sometimes it helps to force all the HTML elements to a common set of rules so that all styles are set to a common set of features that would be applied in all browsers.
But to really help, some HTML examples would be nice.
Hi, yeah I was going to ask about the DOCTYPE, I do have mine set to:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
as that's what Eclipse automatically put in for me.
I've purchased a book on CSS, which has a whole chapter on the box model. Time to get reading
The tip about multiple styles on a DIV is interesting - would never have considered it.
Thanks
#9 Members - Reputation: 172
Posted 06 April 2011 - 11:33 AM
According to the W3C, the rule states that the height of a block element is : Margin + Border + Padding + Content height. Take the following element as an example:
<div style="margin: 10px 0px; padding: 10px 0px; height: 30px;"> This is a test </div>
According to W3C, the height of this element should be 70 pixels. FireFox and Chrome all show it as 70 pixels. The problem comes with IE 7 and IE 8 Quirks mode. Regardless of how it comes up with the number, it's not W3C compliant and it's quite annoying. On the bright side, IE 8 Standards does handle it properly. And with the DOCTYPE set, you shouldn't worry about Quirks mode. IE7 only has ~5% of the browser share anymore and most of those users are business users so I wouldn't worry too much about the compatibility issue with IE and the box-model.
Good judgment is gained through experience. Experience, however, is gained through bad judgment.
Visit http://ajaxmud.net for information about developing web-based games
#10 GDNet+ - Reputation: 1883
Posted 06 April 2011 - 12:26 PM
Even IE 6 implements the box model mostly correctly in standards mode (IE 5 is another story, but I think we can forget about that one). IE 6 will occasionally double up padding for no apparent reason, though this seems to be an unrelated bug.On the bright side, IE 8 Standards does handle it properly.






