为什么使用框架
<div class="login-area">
<div class="login-img">
<img src="..." />
</div>
<div class="login-text">
<a href="...">请点击登录</a>
</div>
</div>
<div class="media">
<div class="media-left">
<img src="..." />
</div>
<div class="media-body media-middle">
<a href="...">请点击登录</a>
</div>
</div>
前端框架对比
<div class="row">
<div class="col-md-8"></div>
<div class="col-md-4"></div>
</div>
<button class="btn btn-primary" type="submit">Button</button>
<div class="ui grid">
<div class="ten wide column"></div>
<div class="six wide column"></div>
</div>
<button class="ui primary basic button">Primary</button>
<div class="row">
<div class="small-3 columns"></div>
<div class="small-9 columns"></div>
</div>
<button type="button" class="primary button">Primary</button>
<div class="uk-grid">
<div class="uk-width-1-2"></div>
<div class="uk-width-1-2"></div>
</div>
<button class="uk-button uk-button-primary" type="button">Primary</button>
<div class="pure-g">
<div class="pure-u-1-2"></div>
<div class="pure-u-1-2"></div>
</div>
<button class="pure-button pure-button-primary">A Primary Button</button>
关于 CSS 预处理器
--autoprefixer
--node-sass
--npm-run-all
--rimraf
--onchange
编写轻量级框架
模块划分
命名策略
--div.form-horizontal
--div.form-group
--label.control-label
--input.form-control
--div.form-horizontal
--div.form-group
--label.control-label
--input.form-control
<button class="btn primary">primary</button>
<table class="table bordered striped">...</table>
<div class="boxes primary">...</div>
栅格系统
<!-- 默认 12 列栅格,所以省略 cols-12 -->
<div class="row">
<div class="col-5"></div>
<div class="col-7"></div>
</div>
<!-- 10 列栅格 -->
<div class="row cols-10">
<div class="col-3"></div>
<div class="col-7"></div>
</div>
表单
<!-- checkbox -->
<div class="checkbox">
<label>
<input type="checkbox" value=""> checkbox
</label>
</div>
<!-- checkbox-inline -->
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox1" value="option1"> checkbox
</label>
<!-- checkbox -->
<div class="checkbox">
<label>
<input type="checkbox" value=""> checkbox
</label>
</div>
<!-- checkbox-inline -->
<div class="checkbox inline">
<label>
<input type="checkbox" value=""> checkbox
</label>
</div>
<!-- checkbox -->
<div class="checkbox">
<input type="checkbox" id="checkbox1" value="">
<label for="checkbox1">checkbox</label>
</div>
<!-- checkbox-inline -->
<div class="checkbox inline">
<input type="checkbox" id="inlineCheckbox1" value="">
<label for="inlineCheckbox1">checkbox</label>
</div>
辅助类
.border-left-right {
border-left: 1px solid #eee;
border-right: 1px solid #eee;
}
.border-top-bottom {
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
}
.border-left {
border-left: 1px solid #eee;
}
.border-right {
border-right: 1px solid #eee;
}
.border-top {
border-top: 1px solid #eee;
}
.border-bottom {
border-bottom: 1px solid #eee;
}
盒组件
主题
总结
Github: https://github.com/nzbin/snack
Demo: https://nzbin.github.io/snack
转载来源:https://segmentfault.com/a/1190000012013908