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 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Using CSS to resize an element as a percentage of the largest available size

    It's a little weird to describe so here is the JavaScript I have that's doing the job now:
    Code:
    function squareResize(percent)
    {
    var min = percent * Math.min(window.innerWidth, window.innerHeight);
    $("#myDiv").height(min);
    $("#myDiv").width(min);
    }
    Basically, I have an element that I need to be as large as it can be, while still being a square.

    Is there any way I can do this with only CSS?

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,606
    Thanks
    6
    Thanked 997 Times in 970 Posts
    Nope.


  •  

    Tags for this Thread

    Posting Permissions

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