width question

Discussion in 'CSS' started by johagulo, Mar 17, 2010.

  1. #1
    hi
    i am trying to use % in css
    i have the body as 100% width
    and a containner inside as 1100px. now in the container i want a div to have a %width, but i want that % to be calculated on the body/viewport size not the 1100.

    eg if i write 50%, then the width should be 400(for 800 resolution monitor) or 512(for 1024 resolution) and it should not be given as 550(that is 50% of 1100)

    any ideas??
     
    johagulo, Mar 17, 2010 IP
  2. steelfrog

    steelfrog Peon

    Messages:
    537
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Unless there's some weird hack I'm not aware of, I don't think that's possible. Widths are determined by the parent element; in this case, your 1100px container. So by default, if you set anything inside that container to 50% width, you'll end up with a 550px value. Do you have an example of what you're trying to achieve? Maybe a screenshot of your design? There's usually another way around that by coding the outlining elements differently.
     
    steelfrog, Mar 17, 2010 IP
  3. johagulo

    johagulo Peon

    Messages:
    879
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    here is the pic of what i wanna achieve. these 3 colums are in the container of 1100. my monitor size is 1350something. when i resize to 1024*768, the grey stuff gets scrolled horizontally which i do not want.
    [​IMG]

    basically i want it like ezinearticles where content is resized accordingly, but there everythign floats left. i dont want floating left coz i need everything center aligned.
     
    johagulo, Mar 17, 2010 IP