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

    Smile defining a class within an id in css

    I have the following HTML

    <div id="footer">
    <div class="content">
    <div id="first column">
    <h1> Hello </h1>

    </div>
    </div>
    </div>

    The ID footer contains the background for the footer, however i do not want all the text right next to the edge, and there will be a lot of text in the footer as well as image so i made a class for the other divs that i will creating to ensure they stay within a certain 'box'.

    I am struggling to understand how I would define this in CSS. I am sure i will need to mention the id footer as well as the class content. however i tried footer.content { } and footer#content {} but neither work and i cant find any info on the internet.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Code:
    #footer .content{
    
    }
    That should point the class .content only within the div with the id="footer". is this what you want?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that seems to be working. however i have the CSS as

    #footer .content {
    width:90%;
    left:5%;
    }

    This is in order to center the class as the text is touching the side of the box. But this has not worked, the width at 90% is working but not the left 5%? Sorry i am not making much sense.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,862
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Use margin-left:5%;
    Or if you need to center the text, use text-align:center;
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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