光明山

vuePress-theme-reco 山妖    2016 - 2020
光明山

Choose mode

  • dark
  • auto
  • light
首页
Category
  • 例子
  • 移动端
  • nginx
  • 框架
  • 提示
  • vue
  • webpack
  • 小程序
Tag
TimeLine
External
author-avatar

山妖

15

Article

16

Tag

首页
Category
  • 例子
  • 移动端
  • nginx
  • 框架
  • 提示
  • vue
  • webpack
  • 小程序
Tag
TimeLine
External

css小技巧

vuePress-theme-reco 山妖    2016 - 2020

css小技巧


山妖 2017-08-08 css3

# 物理像素线(也就是普通屏幕下 1px ,高清屏幕下 0.5px 的情况)采用 transform 属性 scale 实现。

.mod_grid {
    position: relative;
    &::after {
        // 实现1物理像素的下边框线
        content: '';
        position: absolute;
        z-index: 1;
        pointer-events: none;
        background-color: #ddd;
        height: 1px;
        left: 0;
        right: 0;
        top: 0;
        @media only screen and (-webkit-min-device-pixel-ratio: 2) {
            -webkit-transform: scaleY(0.5);
            -webkit-transform-origin: 50% 0%;
        }
    }
    
}

# 对于需要保持高宽比的图,应改用 padding-top 实现

.mod_banner {
    position: relative;
    padding-top: percentage(100/750); // 使用padding-top
    height: 0;
    overflow: hidden;
    img {
        width: 100%;
        height: auto;
        position: absolute;
        left: 0;
        top: 0; 
    }
}

# css 画波浪线边框

.ss {
  margin: auto;
	width: 400px;
	height: 200px;
	border-bottom: none;
	background: radial-gradient(circle at 50% 50%, #ccc 0, #ccc 50%, transparent 0), radial-gradient(circle at 50% 50%, #ccc 0, #ccc 50%, transparent 0);
	background-repeat: repeat-y;
	background-color: white;
	background-size: 40px 40px;
	background-position: -20px 100px, 380px 100px;
}

# 心型的样式

.heart{
	width: 10px;
	height: 10px;
	position: fixed;
	background: #f00;
	transform: rotate(45deg);
	-webkit-transform: rotate(45deg);
	-moz-transform: rotate(45deg);
}
.heart:after, .heart:before{
	content: '';
	width: inherit;
	height: inherit;
	background: inherit;
	border-radius: 50%;
	-webkit-border-radius: 50%;
	-moz-border-radius: 50%;
	position: absolute;
}
.heart:after{
	top: -5px;
}
.heart:before{
	left: -5px;
}

# 文字颜色跑动

.text {
    font-family: 华文行楷, "font-weight bolder";
    max-width: 15rem;
    color: transparent;
    background: -webkit-linear-gradient(45deg, rgb(112, 247, 254), rgb(251, 215, 198), rgb(253, 239, 172), rgb(191, 181, 221), rgb(190, 213, 245)) text;
    animation: 20s linear 0s infinite normal none running run;
}
  • 物理像素线(也就是普通屏幕下 1px ,高清屏幕下 0.5px 的情况)采用 transform 属性 scale 实现。
  • 对于需要保持高宽比的图,应改用 padding-top 实现
  • css 画波浪线边框
  • 心型的样式
  • 文字颜色跑动