Urara-Blog/urara/margin.md
2022-08-14 14:10:39 +08:00

659 B
Raw Blame History

title slug tags created summary lastmod
CSS · Add margin to buttons css-margin
CSS Trick
CSS
2022-01-13T10:04:21.000Z 用helper class为单个按钮加margin防止元素复用时产生不必要的margin 2022-05-07T05:32:49.156Z

用 helper class 为单个按钮加 margin防止元素复用时产生不必要的 margin

HTML

<button class="btn helper">Text</button>

CSS

.helper {
  margin-right: 1.6rem;
}

为按钮增加内边距

如果设置 border 数值为负,周边空间则会收到影响,但用 box-shadow 就不会:

所以可以这样设置:

box-shadow: inset 0 0 0 3px #fff;