News for hackers. Stuff that matters.

Show HN: Centering a Div with Physics, Instead of CSS

http://jared314.github.io/physics-based-page-layout/ (Javascript Required)

After the last CSS centering article, I thought there had to be another way. So, I put together a basic Physics-based Page Layout system using an existing Javascript physics library, for springs, and an existing Javascript CSS parser library, for CSS Selectors and a custom CSS-like DSL. The end goal is to layout DOM elements with springs, and eventually collisions, instead of floats, margins, or padding.

( 4 comments | 9 points | on HN )
Re:Show HN: Centering a Div with Physics, Instead of CSS by meerita on Wednesday February 12, 2014 @04:07AM (#7223283)
No offense: the centering topic is really well covered right now (if you meant to use JS). If you can't resize you're example is really empty in solutions. Plus, depending your target, you can use flexbox and achieve the same with 3 lines of code.
Re:Show HN: Centering a Div with Physics, Instead of CSS by jared314 on Wednesday February 12, 2014 @12:05PM (#7225489)
> No offense: the centering topic is really well covered right now

It sounds like you are fixating on the example of centering, where using a physics model to generate positioning and layouts, without CSS or HTML tables, is the goal.

Re:Show HN: Centering a Div with Physics, Instead of CSS by robmate on Wednesday February 12, 2014 @05:12PM (#7227717)
Why would I want to use a Physics-based Page Layout instead of the traditional layout? What do I win?
Re:Show HN: Centering a Div with Physics, Instead of CSS by jackgolding on Wednesday February 12, 2014 @03:08AM (#7223154)
Was about to say it isn't responsive but I see its on the list!