基础样式

目录结构

dist/ 为生产环境目录,包含 CSS、JavaScript、图片素材 和 用于演示的 HTML 文件。

src/ 存放 Less、JavaScrip 文件源码 和 Sketch 文件。

h5ui/
├── dist/
│   ├── css/
│   ├── example/
│   ├── img/
│   └── js/
├── src/
│   ├── js/
│   ├── less/
│   └── sketch/
├── package.json
├── gulpfile.js
└── server.js

文件引用

基础 CSS 引用

<!-- H5UI CSS -->
<link rel="stylesheet" href="https://h5ui.io/css/h5ui.min.css">

基础 JS 引用

<!-- jQuery -->
<script src="https://h5ui.io/js/jquery.min.js"></script>

<!-- H5UI JS -->
<script src="https://h5ui.io/js/h5ui.min.js"></script>

基本 HTML 模版

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no" />

    <title>H5UI</title>

    <!-- H5UI CSS -->
    <link rel="stylesheet" href="https://h5ui.io/css/h5ui.min.css">

</head>
    <body ontouchstart>

        <!-- start [Module] -->
        <h1>Hello, H5UI!</h1>
        <!-- end [Module] -->

        <!-- jQuery -->
        <script src="https://h5ui.io/js/jquery.min.js"></script>
        <!-- H5UI JS -->
        <script src="https://h5ui.io/js/h5ui.min.js"></script>
    </body>
</html>

base.less

variable.less

// Colors
@colorPrimary: #43AC43;
@colorPrimaryDark: darken(@colorPrimary, 5%);
@colorPrimaryDarker: darken(@colorPrimary, 10%);

@colorRed: #EC5055;
@colorRedDark: darken(@colorRed, 5%);
@colorRedDarker: darken(@colorRed, 10%);

@colorBlack: #000;
@colorGrayDarker: #222;
@colorGrayDark: #666;
@colorGray: #999;
@colorGrayLight: #CCC;
@colorLine: #E5E5E5;
@colorWhite: #FFF;

@backgroundPrimary: #F5F6F7;

// Font family
@fontFamilyPrimary: -apple-system-font, "Helvetica Neue", sans-serif;

reset.less

*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html,
body{
  position: relative;
  height: 100%;
  width: 100%;
}

html {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-tap-highlight-color: transparent;
}

body {
  background: @backgroundPrimary;
  font-family: @fontFamilyPrimary;
  color: @colorGrayDarker;
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.41176471;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  position: relative;
  text-align: left;
}

a {
  color: @colorGrayDarker;
  text-decoration: none;
}

a,
input,
button,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  outline: 0;
}

textarea{
  resize: none;
  vertical-align: middle;
}

img {
  border: 0;
}

small {
  font-size: 80%;
}

// Clearfix
.clearfix:before,
.clearfix:after {
  content: "";
  display: table;
}
.clearfix:after {
  clear: both;
}

// Disabled
.disabled, [disabled] {
  opacity: 0.55;
  pointer-events: none;
}

// Float
.pull-left {
  float: left !important;
}

.pull-right {
  float: right !important;
}

// Text Align
.text-center{
  text-align: center !important;
}
.text-left{
  text-align: left !important;
}
.text-right{
  text-align: right !important;
}

// Page
.h5ui-page{
  &.top{
    padding-top: 15px;
  }
  &.bottom{
    padding-bottom: 15px;
  }
  &.spacing{
    padding: 0 15px;
  }
  &.spacing-cell{
    padding: 15px;
  }
}

1px 细线 Mixin

.module{
  position: relative;
}

<!-- 下边线 -->
.module:before {
    .mixin-hairline_bottom;
}

<!-- 上边线 -->
.module:after {
    .mixin-hairline_top;
}

<!-- 四边线 -->
.module:before {
    .mixin-hairline_full;
}

<!-- 左边线 -->
.module:before {
    .mixin-hairline_left;
}

<!-- 右边线 -->
.module:after {
    .mixin-hairline_right;
}

最后更新于