ie problems..

Discussion in 'C#' started by red_fiesta, Nov 2, 2006.

  1. #1
    I have a problem with divs in firefox and ie.

    the size the divs have to cover is 800px.

    The amout of divs that sits in this space is determined by the number of options which varies from 1 - 10

    so first i work out the size of one div by

    menuIndSize = 800 / mmItems

    mmItems is the number of divs that is required..

    so within a loop i have the code

    
    <div class="menuItem2"  style="width:<%=cdbl(menuIndSize )%>px; background-color:<%=bgcolour%>;"><%=rsMainMenu("Section_Name")%> </div>
    Code (markup):
    In Firefox it always work perfectly in ie it doesnt....

    in ie if for example the items is 4 or 5 it works as

    800 / 4 = 200 and 200 is a whole number

    but if there are only 3 menu options for example

    800 / 3 = 266.666666666667 and this isnt a whole number it doesnt work

    as i said this work perfectly in firefox but in ie its 2 pixels short..

    what can i do??
     
    red_fiesta, Nov 2, 2006 IP
  2. gworld

    gworld Prominent Member

    Messages:
    11,324
    Likes Received:
    615
    Best Answers:
    0
    Trophy Points:
    310
    #2
    menuIndSize = Round((800 / mmItems),0) :)
     
    gworld, Nov 2, 2006 IP
  3. red_fiesta

    red_fiesta Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yeah but then the total can be more than 800, ie 801 if 3 items using round
     
    red_fiesta, Nov 3, 2006 IP
  4. gworld

    gworld Prominent Member

    Messages:
    11,324
    Likes Received:
    615
    Best Answers:
    0
    Trophy Points:
    310
    #4
    menuIndSize = Round((800 / mmItems),0)

    While (menuIndSize*mmItems) >800

    menuIndSize=menuIndSize-1

    Wend


    :)
     
    gworld, Nov 3, 2006 IP
  5. rb3m

    rb3m Peon

    Messages:
    192
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That'll make the total 798 (266 * 3), not 800. The solution is either to substract the lone pixel from the last div or add the 2 extra needed. I would do it by making the loop one iteration shorter than it needs to be, add the last div outside of the loop and make its width equal 800 - (menuIndSize*(mmItems-1)).
     
    rb3m, Nov 3, 2006 IP
  6. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #6
    don't give width to the DIV give it to the table in which it is

    or use JavaScript that'll help you I guess
     
    ludwig, Nov 4, 2006 IP
  7. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #7
    set them up as div 9.9% width
     
    ccoonen, Nov 10, 2006 IP