uniapp公共样式

文章描述:

uniapp如何使用公共样式,减少代码沉淀提高运行效率。

定义

项目根目录common/common.css

主题色、背景、flex布局、内边框、外边框、内边距、文字、宽高、图片大小、阴影、固定位置等。

page {
	height: 100%;
	width: 100%;
	background-color: #F8F8F8;
}

.container {
	height: 100%;
	width: 100%;
}

/*主题色*/
.main-color {
	color: #1bbf80;
}

.white-color {
	color: #ffffff;
}

.black-color {
	color: #333333;
}

.normal-color {
	color: #666666;
}

.gray-color {
	color: #999999;
}

.light-color {
	color: FCCCCCC;
}

/* 背景 */
.bg-white-color {
	background-color: #FFFFFF;
}

.bg-hover-color {
	background-color: #BBBBBB !important;
}

/* flex布局 */
.d-flex {
	display: flex
}

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

.j-start {
	justify-content: flex-start;
}

.j-center {
	justify-content: center;
}

.j-end {
	justify-content: flex-end;
}

.j-sb {
	justify-content: space-between;
}

.j-sa {
	justify-content: space-around;
}

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

.a-start {
	align-items: flex-start;
}

.a-center {
	align-items: center;
}

.a-end {
	align-items: flex-end;
}

.a-stretch {
	align-items: stretch;
}

.a-self-start {
	align-self: flex-start;
}

.a-self-end {
	align-self: flex-end;
}

.flex-shrink {
	flex-shrink: 0;
}

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

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

/* 边框 */
.u-border-radius {
	border-radius: 10rpx;
}

.u-border-radius-big {
	border-radius: 30rpx;
}

.u-border-radius-lg {
	border-radius: 60rpx;
}

.box-content {
	box-sizing: content-box;
}

/* 外边框 */
.mx-5 {
	margin-left: 5rpx;
	margin-right: 5rpx;
}

.mx-10 {
	margin-left: 10rpx;
	margin-right: 10rpx;
}

.mx-20 {
	margin-left: 20rpx;
	margin-right: 20rpx;
}

.mx-30 {
	margin-left: 30rpx;
	margin-right: 30rpx
}

.my-5 {
	margin-top: 5rpx;
	margin-bottom: 5rpx;
}

.my-10 {
	margin-top: 10rpx;
	margin-bottom: 10rpx;
}

.my-20 {
	margin-top: 20rpx;
	margin-bottom: 20rpx;
}

.my-30 {
	margin-top: 30rpx;
	margin-bottom: 30rpx;
}

/* *内边距* */
.px-5 {
	padding-left: 5rpx;
	padding-right: 5rpx;
}

.px-10 {
	padding-left: 10rpx;
	padding-right: 10rpx;
}

.px-20 {
	padding-left: 20rpx;
	padding-right: 20rpx;
}

.px-30 {
	padding-left: 30rpx;
	padding-right: 30rpx;
}

.py-5 {
	padding-top: 5rpx;
	padding-bottom: 5rpx;
}

.py-10 {
	padding-top: 10rpx;
	padding-bottom: 10rpx;
}

.py-20 {
	padding-top: 20rpx;
	padding-bottom: 20rpx;
}

.py-30 {
	padding-top: 30rpx;
	padding-bottom: 30rpx;
}

/* 文字 */
.line-throught {
	text-decoration: line-through;
}

.font-weight {
	font-weight: bold;
}

.d-block {
	display: block;
}

.d-inlinet {
	display: inline;
}

.t-justifyt {
	text-align: justify;
}

/* 宽高 */
.w-100 {
	width: 100%;
}

.w-50 {
	width: 50%;
}

.h-100 {
	height: 100%;
}

.h-50 {
	height: 50%;
}

/* 图片大小 */
.img-345 {
	width: 345rpx;
	height: 345rpx
}

.img-160 {
	width: 160rpx;
	height: 160rpx
}

.limg-80 {
	width: 80rpx;
	height: 80rpx
}

/* 阴影 */
.shadow {
	box-shadow: 0 0 15rpx #999999;
}

/* 固定位置 */
.p-fixed {
	position: fixed !important;
}

.left-0 {
	left: Opx
}

.right-0 {
	right: Opx;
}

.top-0 {
	top: Opx
}

.bottom-0 {
	bottom: 0;
}

调用

根目录App.vue文件

@import "common/common.css";

 

发布时间:2022/05/23

发表评论