sassline icon indicating copy to clipboard operation
sassline copied to clipboard

Adjusting margins for arbitrary borders and padding

Open mmadden opened this issue 11 years ago • 11 comments

I'm really enjoying Sassline so far, especially the breakpoint-specific scales, etc. However, I'm having some difficulty styling a simple <button> that maintains the vertical rhythm and it seems this will be a problem for other elements requiring borders or more padding.

The sassline mixin doesn't seem to have a way to account for additional padding or borders. For example, in the case of a <button> a 1px border causes the inner text to fall 1px below the baseline, and all descendant elements to fall 2px below the baseline. Also padding-top is always greater than padding-bottom which isn't typically desirable in buttons or other form input elements where the text should be vertically centered between the borders.

Please let me know if I'm missing something, but it seems like another mixin or function is needed that also accepts border and/or padding arguments and automatically adjusts the top/bottom margins to maintain the vertical rhythm by snapping to the closest fitting n lines of the current baseline.

When this is a solved use case (or if it is already), perhaps we can update the Sassline demo to include basic form elements.

Keep up the great work Jake!

mmadden avatar Sep 24 '14 17:09 mmadden

Hi Matthew, I’ll look into getting something sorted for form elements. Thanks!

jakegiltsoff avatar Sep 29 '14 14:09 jakegiltsoff

+1

pjhawksr avatar Jan 17 '15 17:01 pjhawksr

This would be a great feature for many use cases. +1.

bobcolner avatar Jan 20 '15 07:01 bobcolner

+1

lukakemperle avatar Mar 12 '15 06:03 lukakemperle

+1

iolla-net avatar May 10 '15 21:05 iolla-net

A workaround for now that can easily be used is to apply the baseline mixin to a containing element.

For example wrap a button in a div with class .button-align, then use

.button-align { @include baseline(zeta, $bodytype, 2, 2, all); }

screen shot 2015-05-31 at 22 32 57

When I have time I will look into a mixin that can control additional vertical padding/borders and add some examples to the demo.

jakegiltsoff avatar May 31 '15 21:05 jakegiltsoff

Thanks Jake, very much appreciated.

iolla-net avatar May 31 '15 23:05 iolla-net

This is especially ironic given that the button captions on sassline.com are off the baseline...! Thanks for the workaround details.

OliverM avatar Feb 12 '16 13:02 OliverM

@OliverM It made more sense to me to have the buttons themselves fit to the baseline there.

jakegiltsoff avatar Feb 12 '16 13:02 jakegiltsoff

@jakegiltsoff Thanks!

pjhawksr avatar Feb 12 '16 13:02 pjhawksr

Yeah, there's no non-button text on either side so it makes sense that the visual rhythm would match the button borders. By way of background, I'm designing forms with 20+ input fields of various types, each with text labels, so the workaround above is great to have.

OliverM avatar Feb 12 '16 13:02 OliverM