vue和uniapp公共样式

38 篇文章 6 订阅

vue使用less

reset.less

* {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}
button,
input,
select,
textarea {
  margin: 0;
}
html {
  box-sizing: border-box;
}
*,
*::before,
*::after {
  box-sizing: inherit;
}
img,
video {
  height: auto;
  max-width: 100%;
}
iframe {
  border: 0;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
td,
th {
  padding: 0;
}
td:not([align]),
th:not([align]) {
  text-align: left;
}
i {
  font-style: normal;
}

theme.less

// less变量
@black: #000;
@white: #fff;
@gray-1: #333;
@gray-2: #666;
@gray-3: #999;
@gray-4: #eee;
@gray-5: #f8f8f8;

@red: #E91010;
@yellow:#FB8D32;
@blue: #2E93FF;

// border
@border-color: @gray-4;
@border-width-base: 1px;

common.less

@import './reset.less';
@import './theme.less';

html, body {
  height: 100%;
}
//pc
// .w{
//   width: 1280px;
//   margin: auto;
// }
// a {
//   color: inherit;
// }

// Color
@colors: black, white, gray-1, gray-2, gray-3, gray-4, red, blue,yellow;

each(@colors, {
  .@{value} {
    color: @@value;
  }
});
each(@colors, {
  .bg-@{value} {
    background-color: @@value;
  }
});

each(range(10,100,2), {
  .size-@{value} {
    font-size: @value*1px;
  }
})
each(range(5,30,5), {
  .radius-@{value} {
    border-radius: @value*1px;
  }
})
each(range(100), {
  .pd-@{value}, .ptb-@{value}, .pt-@{value} { padding-top: @value*1px; }
  .pd-@{value}, .ptb-@{value}, .pb-@{value} { padding-bottom: @value*1px; }
  .pd-@{value}, .plr-@{value}, .pl-@{value} { padding-left: @value*1px; }
  .pd-@{value}, .plr-@{value}, .pr-@{value} { padding-right: @value*1px; }
  .mg-@{value}, .mtb-@{value}, .mt-@{value} { margin-top: @value*1px; }
  .mg-@{value}, .mtb-@{value}, .mb-@{value} { margin-bottom: @value*1px; }
  .mg-@{value}, .mlr-@{value}, .ml-@{value} { margin-left: @value*1px; }
  .mg-@{value}, .mlr-@{value}, .mr-@{value} { margin-right: @value*1px; }
})

.bg{
  background-color:@gray-5;
}

.bold {
  font-weight: 700;
}

//border
.bt {
  border-top: @border-width-base / 2 solid @border-color;
}
.br {
  border-right: @border-width-base / 2 solid @border-color;
}
.bb {
  border-bottom: @border-width-base / 2 solid @border-color;
}
.bl {
  border-left: @border-width-base / 2 solid @border-color;
}
.border{
  border: @border-width-base / 2 solid @border-color;
}


// utils
.relative {
  position: relative;
}
.absolute {
  position: absolute;
}
.fixed {
  position: fixed;
}
.fixed-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  position: fixed;
}
.inline-block {
  display: inline-block;
}
.hide {
  display: none !important;
}
.show {
  display: block !important;
}
.autowrap {
  word-wrap: break-word;
  word-break: normal;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.over-hidden {
  overflow: hidden !important;
}

.scroll-y {
  overflow-y: auto;
}

// 小曲的样式
.min100{
  min-height: 100vh;
}
.w100{
  width: 100%;
}
.h100{
  height: 100%;
}
.line-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 两行超出显示省略号 */

.line-2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

//flex
.flex {
  justify-content: space-between;
  display: flex;
  align-items: center;
}

.flex_l {
  justify-content: flex-start;
  display: flex;
  align-items: center;
}

.flex_r {
  justify-content: flex-end;
  display: flex;
  align-items: center;
}

.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex1 {
  display: flex;
}

.flex-inline {
  display: inline-flex;
}

.flex::before,
.flex::after,
.flex-inline::before,
.flex-inline::after {
  display: none;
}

.flex-left {
  justify-content: flex-start;
}
.flex-center {
  justify-content: center;
}
.flex-right {
  justify-content: flex-end;
}
.flex-between {
  justify-content: space-between;
}
.flex-around {
  justify-content: space-around;
}

.flex-stretch {
  align-items: stretch;
}
.flex-top {
  align-items: flex-start;
}
.flex-middle {
  align-items: center;
}
.flex-bottom {
  align-items: flex-end;
}

.flex-row {
  flex-direction: row;
}
.flex-row-reverse {
  flex-direction: row-reverse;
}
.flex-column {
  flex-direction: column;
}
.flex-column-reverse {
  flex-direction: column-reverse;
}

.flex-nowrap {
  flex-wrap: nowrap;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-wrap-reverse {
  flex-wrap: wrap-reverse;
}


each(range(12), {
  .flex-@{value} {
    flex: @value;
  }
});

uniapp使用scss

uni.scss

/* uni.scss */
@import 'uview-ui/theme.scss';

/* 颜色变量 */
$bg:#f8f8f8;
$bg-1:#ccc;
$blue:#0072FF;
$white:#fff;
$yellow:#FF9900;
$red:#FE0000;
// $yellow:#F59E12;
$gray:#333;
$gray-1:#666;
$gray-2:#999;


/* 边框border */
$border-width-base:1rpx;
$border-color:#f8f8f8;
$radius:5rpx;

common.scss

/* 颜色 */
.red{
	color:$red;
}
.blue{
	color: $blue;
}
.white{
	color:$white;
}
.yellow{
	color:$yellow;
}
.gray{
	color:$gray;
}
.gray-1{
	color:$gray-1;
}
.gray-2{
	color:$gray-2;
}
.bg{
	background-color: $bg;
}
.bg-white{
	background-color: $white;
}
.bg-blue{
	background-color: $blue;
}
.bg-yellow{
	background-color:$yellow;
}


/* flex */
.center{
	display: flex;
	justify-content: center;
	align-items: center;
}
.flex1{
	display: flex;
	justify-content: space-between;
	align-items: center;
}
.flex_l{
	display: flex;
	justify-content: flex-start;
	align-items: center;
}
.flex_r{
	display: flex;
	justify-content: flex-end;
	align-items: center;
}
.flex{
	display: flex;
}
.flex-center{
	justify-content: center;
}
.flex-around{
	justify-content: space-around;
}
.flex-between{
	justify-content: space-between;
}
.flex-top{
	align-items: flex-start;
}
.flex-middle{
	align-items: center;
}
.flex-bottom{
	align-items: flex-end;
}
.flex-column{
	flex-direction: column;
}
.flex-wrap{
	flex-wrap: wrap;
}

/* 边框 */
.bt {
  border-top: $border-width-base solid $border-color;
}
.bb {
  border-bottom: $border-width-base solid $border-color;
}
.bl {
  border-left: $border-width-base solid $border-color;
}
.br {
  border-right: $border-width-base solid $border-color;
}
.border{
	 border: $border-width-base solid $gray-2;
}

.border-yellow{
	 border: $border-width-base solid $yellow;
}



/* 全屏 */
.vw100 {
  width: 100vw !important;
}
.vh100 {
  height: 100vh !important;
}
.min100 {
  min-height: 100vh !important;
}
.h100 {
  height: 100% !important;
}
.w100 {
  width: 100% !important;
}

/* 其他 */
.relative{
	position: relative;
}
.absolute{
	position: absolute;
}
.fixed{
	position: fixed;
}
.fixed-bottom{
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
}
.block{
	display: block;
}
.hide {
  display: none;
}
.show {
  display: block;
}
.autowrap {
  word-wrap: break-word;
  word-break: normal;
}
.text-left {
  text-align: left;
}
.text-center {
  text-align: center;
}
.text-right {
  text-align: right;
}
.bold {
  font-weight: 600;
}
.over-hidden {
  overflow: hidden;
}
.bold{
	font-weight: 700;
}

/* uview内置样式 */
/* u-line-1,u-line-2  一行省略 */
/* u-font-26  x>= 20 && x <= 40时,表现为rpx性质 */
/* 
u-padding-x == u-p-x
u-padding-left-x == u-p-l-x
u-padding-top-x == u-p-t-x
u-padding-right-x == u-p-r-x
u-padding-bottom-x == u-p-b-x
u-margin-x == u-m-x
u-margin-left-x == u-m-l-x
u-margin-top-x == u-m-t-x
u-margin-right-x == u-m-r-x
u-margin-bottom-x == u-m-b-x 
取值范围:
1-80(可以等于80)之间的偶数(双数) 和 5的倍数
*/

/* 
 .u-flex-1 {
 	flex: 1; 取值范围 1~12
 }
 */
// padding margin
@for $value from 1 through 100{
  .pd-#{$value}, .ptb-#{$value}, .pt-#{$value} { padding-top: $value*1rpx; }
  .pd-#{$value}, .ptb-#{$value}, .pb-#{$value} { padding-bottom: $value*1rpx; }
  .pd-#{$value}, .plr-#{$value}, .pl-#{$value} { padding-left: $value*1rpx; }
  .pd-#{$value}, .plr-#{$value}, .pr-#{$value} { padding-right: $value*1rpx; }
  .mg-#{$value}, .mtb-#{$value}, .mt-#{$value} { margin-top: $value*1rpx; }
  .mg-#{$value}, .mtb-#{$value}, .mb-#{$value} { margin-bottom: $value*1rpx; }
  .mg-#{$value}, .mlr-#{$value}, .ml-#{$value} { margin-left: $value*1rpx; }
  .mg-#{$value}, .mlr-#{$value}, .mr-#{$value} { margin-right: $value*1rpx; }
}

// size
@for $value from 20 through 50{
  .size-#{$value}{ font-size: $value*1rpx; }
}
// radius
@for $value from 5 through 20{
  .radius-#{$value}{ border-radius: $value*1rpx; }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小曲曲

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值