Live data from Hacker News

CSS: Absolutely positioning things relatively

canvatechblog.com

21–30 of 42 posts

Re: CSS: Absolutely positioning things relatively

#21

I don't understand why we're even talking about javascript? Responsiveness has always worked fine on css. Even without grid, you could easily make a good responsive layout

The article doesn't contain any JS. JS is mentioned because it's a possible solution to generating responsive layouts without hand writing any CSS. The whole purpose of the article is to explore generating responsive style from a user designed layout without manually writing the CSS code. It's an unsolved problem domain.

Re: CSS: Absolutely positioning things relatively

#23
post #20

In media query section, a gif that shows text block going down, you can see that at mobile scales the spacing between social icons jumps suddenly for seemingly no reason. Was that intended? In a gif between “It’s probably best to show you” and “Voila”, social icons don’t stick to the image, dangling at the bottom instead. How to make them stick? Asking it because most commenters here seem to praise the grid, but igno…

As a follow up, I’d like to try expressing the same with constraints instead of a grid. E.g.:

$image is at the top left, xy-padded by P, which is 5% of its width. To the right of it x-padded by P on both sides is a $textblock, with a minimum width of that of the image, aligned by top. If their natural/defined minimums make them not fit the width of the screen, $textblock goes below the $socialbtns padded by P/2, aligned by width of $image. $socialbtns are below the image aligned to the left, y-padded by P/2.

This should be expressed more formally, but you get the idea. Why can’t we just do this and instead have to solve some unique puzzle by hand every time we need some layout?

(Made few edits to constraints, now seems fine)

Re: CSS: Absolutely positioning things relatively

#24
post #4

Nice technique. Reminds me of the old days of the web, when everything was done with TABLEs.

Exact same feeling here, everything old is new again when a generation has grown up without experiencing it.

Anyone who has coded an html email is very familiar with tables

Re: CSS: Absolutely positioning things relatively

#27
post #20

In media query section, a gif that shows text block going down, you can see that at mobile scales the spacing between social icons jumps suddenly for seemingly no reason. Was that intended? In a gif between “It’s probably best to show you” and “Voila”, social icons don’t stick to the image, dangling at the bottom instead. How to make them stick? Asking it because most commenters here seem to praise the grid, but igno…

It does jump, but perhaps this is an unintended consequence that makes it easier to tap those icons?

Re: CSS: Absolutely positioning things relatively

#28
post #23
post #20

In media query section, a gif that shows text block going down, you can see that at mobile scales the spacing between social icons jumps suddenly for seemingly no reason. Was that intended? In a gif between “It’s probably best to show you” and “Voila”, social icons don’t stick to the image, dangling at the bottom instead. How to make them stick? Asking it because most commenters here seem to praise the grid, but igno…

As a follow up, I’d like to try expressing the same with constraints instead of a grid. E.g.: $image is at the top left, xy-padded by P, which is 5% of its width. To the right of it x-padded by P on both sides is a $textblock, with a minimum width of that of the image, aligned by top. If their natural/defined minimums make them not fit the width of the screen, $textblock goes below the $socialbtns padded by P/2, alig…

Android has ConstraintLayout with some of that, but it's just "spaces between sibling edges", not quite as flexible as you describe.

Re: CSS: Absolutely positioning things relatively

#29
> But what if we flipped this? What if we first look at the position of the elements that we want to render and then create all the columns and rows from them.

What's old is new again!

This immediately brought me back to 2005 and apps like Dreamweaver or Fireworks that'd let you drag and drop your components onto a page, and underneath the covers would create some very complex (but clever) HTML table structure, complete with sliced and diced images and invisible pixels to space things correctly.

The underlying code wasn't pretty, but the sites did tend to render correctly, even in browsers like IE6.

Though back in those days, nobody had to worry about 6" phone screens, so not sure how well it'd scale (down) today.

Post reply on HN