Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:42:29+00:00 2026-05-24T18:42:29+00:00

Is there a purely CSS-based way to size a block-level element such that it

  • 0

Is there a purely CSS-based way to size a block-level element such that it fills its parent as much as possible, but remains square?


An interesting use case

I have written a very simple analogue clock using mostly CSS, and a pinch of JavaScript.

http://jsbin.com/iqicuk

It has been written scalably:

http://jsbin.com/emiyer

I would like to scale it to fill the page, but stay in proportion, obviously.

If I set the width and height of #clock to 100%, of course, it will be pulled out of proportion:

http://jsbin.com/esubol

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:42:30+00:00Added an answer on May 24, 2026 at 6:42 pm

    A solution in progress

    thirtydot came up with a very clever technique that takes advantage of the fact that images with only one defined dimension scale proportionately, and he harnesses this to size the element. We now have a clock that can scale properly, but only if the viewport width is greater than the height, not the other way around:

    http://jsbin.com/isixug

    Likewise, if we change img and #clock to have a defined width, instead of a defined height, then we have a clock that can scale properly, but only if the viewport height is greater than the width:

    http://jsbin.com/awucun


    The solution

    We can combine the two ‘tricks’ above, that each only work for one orientation, by using a media query for orientation, and specifying the right ‘trick’ depending on the viewport orientation. We now have a completely scalable clock, no matter what the viewport orientation or size:

    http://jsbin.com/okodib

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way purely with CSS (or 'proper' markup) to style the 2nd
Is there a way to customize a scrollbar with only CSS that effects a
Is there a way to make the borders of an element semi-transparent? using purely
Is there any chance that a SHA-1 hash can be purely numeric, or does
Quite simply: is there a place such as DeviantArt, but purely for the purpose
Is there a module written purely in Python that will allow a script to
Is there any way, purely in MSSQL, to determine if the following maxtrix would
I was wondering if there is a way to do this purely in sql:
Does anyone know if there are CSS templates purely for documentation purposes? I haven't
Is there a purely SQL way to do this? I have a table apples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.