Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts

    Text align center not working in Firefox.

    Why?

    The div with the magenta border is supposed to occur in the center. It does in IE, but not in Firefox.

    I thought CSS code was supposed to cascade? To me, this means if we place rules in the body, those rules should be inherited (obeyed) by anything in the body!?

    I know the div is not technically a 'text' element, but the body text centering rule was put there to center the site in IE.

    Code:
    /*Body*/
    *{margin:0;padding:0;}
    body{text-align:center;background:#ccc url(../interface/body_background.jpg) center top repeat-x;font-size:85%;font-family:Arial, Helvetica, Sans serif;color:black}
    /*structure---------------*/
    #wrapper {width:710px;margin-top:80px;margin-left:auto;margin-right:auto;padding:20px}
    #masthead{height:120px}
    #column_1{width:40%;position:relative;top:5px;left:20px}
    #column_2{width:40%}
    #footer{clear:both;height:60px;margin-top:20px}
    /*Text Formatting---------------*/
    #masthead blockquote{font-size:1em;margin-top:20px;margin-right:190px}
    #masthead h1{font-size:2em}
    #title_1{font-size:1em;margin-top:20px;margin-bottom:10px}
    p{font-size:1em;text-align:justify;margin-right:20px;width:40%}
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <title>Welcome to Blinding Horror</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="style/sheet-2.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    	<div id="wrapper" class="border_R">
    		<div id="masthead" class="border_G">
    			<blockquote>
    				Welcome To
    			</blockquote>
    			<h1>
    				BLINDING HORROR
    			</h1>
    		</div>
    		<h2 id="title_1">
    			Central Page Title
    		</h2>
    		<div id="column_1" class="border_M">
    				&nbsp;
    		</div>
    		<div id="footer" class="border_G">
    				&nbsp;
    		</div>
    	</div>
    &nbsp;
    </body>
    </html>
    Last edited by Doctor_Varney; 01-12-2010 at 02:48 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The div with the magenta border is supposed to occur in the center. It does in IE, but not in Firefox.
    There's no such rule in the above posted CSS.

    If you are talking about the div having class="border_M", you need to change your CSS like
    Code:
    #column_1{width:40%;position:relative;top:5px;
    /*left:20px;*/ 
    margin:0 auto;
    }
    Last edited by abduraooft; 01-12-2010 at 03:00 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #4
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    I see, so the center tag is depreciated now. Great! Just when I having SO much fun with it...

    Dr. V
    Last edited by Doctor_Varney; 01-13-2010 at 04:36 AM.

  • #5
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    Quote Originally Posted by abduraooft View Post
    There's no such rule in the above posted CSS.

    If you are talking about the div having class="border_M",
    Yes, that's exactly what I am talking about. The div with the magenta border.

    Quote Originally Posted by abduraooft View Post
    you need to change your CSS like
    Code:
    #column_1{width:40%;position:relative;top:5px;
    /*left:20px;*/ 
    margin:0 auto;
    }
    Yes but I might not want the div to sit centrally, eventually. The point is, the center rule does not cascade in Firefox - but then this div is now stuck in the center in IE. Now I'm presuming Firefox will not recognise the rule for anything other than text? The whole purpose of me using text-align:center, is so the site will center in IE, because it wasn't recognising the margin:auto rule.

    Edit: I have removed the text aligning from the body. Let's hope these margins work...

    Regards

    Dr. V
    Last edited by Doctor_Varney; 01-13-2010 at 04:38 AM.

  • #6
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    And surprise, surprise... They don't!

    You'll notice I've taken out this ('depreciated' but very useful) tag called 'text-align:center; and introduced margins to the H1 & H2 elements, yet the auto-margin is ignored in both browsers. Fantastic!!!

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <html>
    <head>
    <title>Welcome to Blinding Horror</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="style/sheet-2.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <div id="wrapper" class="border_R">
            <div id="masthead" class="border_G">
                <blockquote>
                    Welcome To
                </blockquote>
                <h1>
                    BLINDING HORROR
                </h1>
            </div>
            <h2 id="title_1">
                Something In The Middle By Way Of A Title
            </h2>
            <div id="column_1" class="border_M">
                &nbsp;
            </div>
            <div id="column_2" class="border_M">
                &nbsp;
            </div>
            <div id="footer" class="border_G">
                &nbsp;
            </div>
        </div>
    &nbsp;
    </body>
    </html>
    Code:
    /*CSS Document by Ade Varney 2008*/
    /*Body*/
    *{margin:0;padding:0;}
    body{background:#ccc url(../interface/body_background.jpg) center top repeat-x;font-size:85%;font-family:Arial, Helvetica, Sans serif;color:black}
    /*structure---------------*/
    #wrapper {width:710px;margin-top:80px;margin-left:auto;margin-right:auto;padding:20px}
    #masthead{height:120px}
    #column_1{margin-left:auto;margin-right:auto;width:40%}
    #column_2{margin-left:auto;margin-right:auto;width:40%}
    #footer{clear:both;height:60px;margin-top:20px}
    /*Text Formatting---------------*/
    #masthead blockquote{font-size:1em;margin-top:20px;margin-right:190px}
    #masthead h1{margin-left:auto;margin-right:auto;font-size:2em}
    #title_1{font-size:1em;margin-left:auto;margin-right:auto;margin-top:20px;margin-bottom:10px}
    p{font-size:1em;text-align:justify;margin-right:20px;width:40%}
    /*Temporary Borders-------------*/
    .border_R{border:1px solid red}
    .border_G{border:1px solid green}
    .border_B{border:1px solid blue}
    .border_C{border:1px solid cyan}
    .border_M{border:1px solid magenta}
    .border_Y{border:1px solid yellow}
    .border_K{border:1px solid black}
    .border_E{border:1px solid gray}
    .border_H{border:1px solid white}
    /*End CSS*/
    Now to go back and look at the code you suggested earlier, Abdura...

    Thanks

    Dr. V
    Last edited by Doctor_Varney; 01-13-2010 at 05:15 AM.
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

  • #7
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    The CSS Text Align Property is not deprecated. text-align:center; is perfectly valid.

    HTML <center> tag is deprecated.

    CSS is for styling your content - so it makes perfect sense that <center> does not belong in the markup.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #8
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    Of course... I confused the word tag with CSS property. Thanks, Excavator, for elucidating.
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •