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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    override parent css

    I am having trouble overriding padding and margin css on a class I have created for headers.

    I would like to make all my h2 tags that I specify with a class to remove all padding and margin that is being inherited from the parent class.

    https://www.icsworld.com/Find_Local_.../Missouri.aspx

    Here is an example. Each of the H2 tags within the body content have received a class called .headerBlock

    my headerBlock CSS is as follows
    Code:
    .headerBlock h2 {
    	background: #FFFFCC;
    	margin: 0 px;
    	padding: 0 px;
    	border-top: solid 1px #C0C0C0;
    	border-bottom: solid 1px #C0C0C0;
    	text-align: center;
    
    
    }
    However I think my css is being overwritten by the .PageText class.

    My understanding is the child class needs to be more specific in order for it to override it's parent but I seem to be having trouble formatting the rule for it to properly generate.

    Can someone point me in the right direction?

    Thanks

  • #2
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    Where are you using h2? I can't seem to locate usage of h2.

  • #3
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,305
    Thanks
    11
    Thanked 283 Times in 282 Posts
    The usage you're making of the class headerBlock is like this:
    <h2 class="headerBlock">Missouri..... </h2>

    So your CSS to control the style of that should look like:
    h2.headerBlock {padding..... }

    Coincidentally you have this style on line 430 of your style.css file, but you have not set the padding and what-not for that style.

    Dave


  •  

    Tags for this Thread

    Posting Permissions

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