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
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <div> CSS box problem

    Hi

    I'm new to using <div> and css to create a layout for a site, im used to using <table> and css.

    My question is thus. On the following site i have a box which will go around any message or form on my site. The problem is that the box covers the entire width of the page and i only want it to wrap around its contents, (IE the login form on the example page below) i just can't figure out how to do it.

    The site is...
    http://www.thecoldwars.com/flytrap/

    TIA

  • #2
    New Coder
    Join Date
    Sep 2007
    Posts
    24
    Thanks
    4
    Thanked 1 Time in 1 Post
    Are you talking about the div with the id "container" or the div with the id "box"?

    Either way, to edit the width you can do something like this:

    Code:
    #container{
    width: 200px;
    }
    or

    Code:
    #container{
    width: 50%;
    }
    All you need to do is define the width. You can define the width by using pixels (px), percentages (50%), etc.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You then need to float the element if you want other <div></div> elements to be next to it.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    New to the CF scene
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My bad, should have gone into a bit more detail.

    The problem <div> is the one with the ID 'box'. I want it to automatically fit around whatever is in the <div> i can't use a fixed width because the contents could be bigger or smaller on different pages.

    Thanks for your help


  •  

    Posting Permissions

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