Hacker News new | ask | show | jobs
Ask HN: CSS design question
2 points by blawa 4112 days ago
This is a followup (very specific though) to the question I asked a couple of days back: https://news.ycombinator.com/item?id=9162139

Thank you for the helpful answers there. I'm still going through the excellent links in question (and trying to lay my hands on a couple of the books mentioned) but I wonder if you guys could make suggestions for the following situation:

I have a block that can be used in two scenarios:

* list of suck blocks

* individual block placed among others of different kind

What are the best practices for deciding its margin?

Say the block has class `main` and a precending and a following block are respectively classed `preceding` and `following` for the second scenario.

If I set a margin for `main` and for the second scenario, I need `preceding` and `following` to be touching `main`, then should I set negative margin's on preceding and following?

Or another solution is to set margins using immediate sibling selector `.main+.main` and not for `.main`.

I am sure I'm missing things, so what are the possible solutions and what are the best practices here?

I hope by this question, I have also managed to give a solid example of the kind of advice I was seeking in my last question. So if you guys want to re-answer my last question, i.e. resources for CSS Design Patterns, that would be great too! Thank you!