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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Location
    UK, England
    Posts
    268
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Div tags and pixel/percents

    Bit of a basic one...

    I was considering today what do you use when having a div tag with text inside it? Should I be using pixel/percent - and why?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I usually make all of my web pages a fixed width of 950px.
    So my <div> sections are also fixed at various pixel widths.

    If you want a fluid width page that changes widths based
    on browser width, then you use percents.

    It's simply a matter of personal preference.

    This page (coding forums) that you're now viewing is based on percent.
    Try resizing the width of your browser and see what happens.

  • #3
    Regular Coder
    Join Date
    Apr 2006
    Location
    UK, England
    Posts
    268
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I am trying to create about 2-3 lines of text in the centre of the page. But when I resize my browser, I don't want it to change form and stretch and space out over 5 lines. I've tried both pixel and percentages.

  • #4
    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
    You may need to set a min-width to the container.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Use inline CSS to control just those few lines ...

    <span style="width:250px; text-align:justify;">
    This is the text that makes up the few lines of content. blah blah blah blah
    </span>

    You can style that text however you want and it will then take-on your new
    style, separately from the <div> where it resides.

  • #6
    Regular Coder
    Join Date
    Apr 2006
    Location
    UK, England
    Posts
    268
    Thanks
    2
    Thanked 0 Times in 0 Posts
    It's prob easier if I show you the site if you resize the browser, you can see the words at the bottom blue area adjusting - I don't want this, I want them to fix fixed as you would see them in a normal res.

    Is what you've told me suitable for that?

  • #7
    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
    Then set a width to that div or even a min-width. Wrapping them in a span won't work because you can't set a width on a span unless you make it display:block.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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