2020-12-01 11:43:30 +08:00
|
|
|
|
/*!markdown
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
title: Box Sizing
|
|
|
|
|
---
|
|
|
|
|
|
2020-12-08 19:57:59 +08:00
|
|
|
|
Box Sizing 相关样式,主要区别在于设置宽高的时候,是否包含了 padding 和 border 的大小。
|
2020-12-01 11:43:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Class | Properties |
|
|
|
|
|
| ----------- | ------------------------ |
|
|
|
|
|
| box-border | box-sizing: border-box; |
|
|
|
|
|
| box-content | box-sizing: content-box; |
|
|
|
|
|
|
2020-12-10 14:09:24 +08:00
|
|
|
|
## 用法
|
|
|
|
|
|
2020-12-10 17:50:24 +08:00
|
|
|
|
比如这个例子:左侧是 box-border 类型,整体高宽 128px。而右侧只是内容区域是 128px + 边框(2 * 4px) + padding (2 * 16px) 一共160px。
|
2020-12-01 11:43:30 +08:00
|
|
|
|
|
2020-12-08 19:57:59 +08:00
|
|
|
|
```html
|
|
|
|
|
<div class="flex space-x-6">
|
|
|
|
|
<div class="box-border h-32 w-32 p-4 border-4 border-blue-400 bg-blue-200 rounded-md">
|
|
|
|
|
<div class="h-full w-full bg-red-400"></div>
|
|
|
|
|
</div>
|
2020-12-01 11:43:30 +08:00
|
|
|
|
|
2020-12-08 19:57:59 +08:00
|
|
|
|
<div class="box-content h-32 w-32 p-4 border-4 border-blue-400 bg-blue-200 rounded-md">
|
|
|
|
|
<div class="h-full w-full bg-red-400"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
```
|
2020-12-09 00:35:24 +08:00
|
|
|
|
|
2020-12-10 14:09:24 +08:00
|
|
|
|
## 响应式设计
|
|
|
|
|
|
2020-12-21 10:08:40 +08:00
|
|
|
|
不支持 [「响应式设计前缀」](../../../docs/style/responsive-design.md),有需求请提 [issue](https://github.com/baidu/amis/issues)。
|
2020-12-10 14:09:24 +08:00
|
|
|
|
|
|
|
|
|
## 状态前缀
|
|
|
|
|
|
2020-12-21 10:08:40 +08:00
|
|
|
|
不支持[「状态前缀」](../../../docs/style/state.md),有需求请提 [issue](https://github.com/baidu/amis/issues)。
|
2020-12-10 14:09:24 +08:00
|
|
|
|
|
2020-12-01 11:43:30 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2020-11-25 23:47:36 +08:00
|
|
|
|
@mixin make-box-sizing($prefix: '.') {
|
|
|
|
|
#{$prefix}box-border {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#{$prefix}box-content {
|
|
|
|
|
box-sizing: content-box;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@include make-box-sizing();
|