The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jquery for setting a dynamic max-width

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #35226

    Uhm. Well i am really not well equipped with jquery knowledge therefore giving me the complete code would be the solution. =]

    The function will be
    1.get the 70% width of the browser’s screen.
    2.convert that width into its corresponding px value
    3.set the max width of the #mainContainer using the value got from the conversion/calculation.

    Need help thanks.
    here is the css style for the container i want to set max-width with.

    min-width:940px;/* 940px absolute value of 70%. *
    margin:0 auto;
    /*serves as a divider from content to the main container*/
    -webkit-border-radius: 10px;
    border-radius: 10px;

    well yea it is but the purpose if this is to get the px version of the 70% of the window document so that i can use the value to set it to be the max width.


    But why don’t you just use 70%?

    <<< confused


    can i ask why? and for what purpose? the max-width would be 70% and that should be all you need for styling. Not sure why you would need the px version of 70%….they are the same. 70% of a page that is 1000px is 700px. 700px = 70%


    im setting it to a static max width to limit its container in case the user zoom out the page. and all contents will then stay intact. if i plainly use percentage once the page is zoomed out contents go crazy.
    see here:

    try zooming it out.


    Looks fine when zooming in and out for me.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.