2

I'm trying to build a mobile only HTML page which splits the screen into tiles.

I have 5 tiles per row, so the tile width is determined as 20% of the screen. I would like the height to be the same - 20% of the screen width. Note that's hight = 20% of device width, not height. The page will scroll downward if there are more tiles.

Is there any way to do this with CSS? I'd rather not have to javascript unless I have to.

3
  • 1
    not possible without javascript Commented Jul 4, 2012 at 16:42
  • possible duplicate of CSS: A way to maintain aspect ratio when resizing a DIV? Commented Jul 4, 2012 at 22:58
  • The other posters question is close enough to be considered a duplicate. Good catch. Commented Jul 4, 2012 at 23:24

1 Answer 1

1

I don't believe CSS can do it by itself. Use Javascript, or better and easier, use LessCSS ( lesscss.org )

Sign up to request clarification or add additional context in comments.

3 Comments

Less is compiled css... by javascript. No js in the runtimes. Fyi - and i dont think less can facilitate this.. SASS maybe but that uses runtime js
@SimonAndréForsberg JavaScript is just one way to compile less. Have a look at dotless for .Net for instance. I believe there is a ported version for most web related languages these days.
That's too bad. It seems like it would be a fairly frequent use-case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.