0.5px边框,css及sass
2016-05-28 10:41
399 查看
手机上的边框,1px的宽度已经无法满足需求了,0.5px的需求应用而生。
做法:
利用伪类,做一个长宽200%,1px宽度的边框,再缩小至0.5倍。
div {
position: relative;
}
div:before {
content: '';
position: absolute;
left: 0;
top: 0;
border: 1px solid #fff;
border-width: 0 0 1px;
width: 200%;
height: 200%;
transform: scale(.5, .5);
box-sizing: border-box;
transform-origin: 0 0;
}这样就是底0.5px的边框了;
sass:$color_border:#ddd;
$border:1px solid $color_border;
@mixin border_s($top:0, $right:0, $bottom:0, $left:0) {
position: relative;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
border: $border;
border-width: $top $right $bottom $left;
width: 200%;
height: 200%;
transform: scale(.5, .5);
box-sizing: border-box;
transform-origin: 0 0;
}
}
.exm {
@include border_s(1px 0 1px);
}
方便复用,边框需求变幻
做法:
利用伪类,做一个长宽200%,1px宽度的边框,再缩小至0.5倍。
div {
position: relative;
}
div:before {
content: '';
position: absolute;
left: 0;
top: 0;
border: 1px solid #fff;
border-width: 0 0 1px;
width: 200%;
height: 200%;
transform: scale(.5, .5);
box-sizing: border-box;
transform-origin: 0 0;
}这样就是底0.5px的边框了;
sass:$color_border:#ddd;
$border:1px solid $color_border;
@mixin border_s($top:0, $right:0, $bottom:0, $left:0) {
position: relative;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
border: $border;
border-width: $top $right $bottom $left;
width: 200%;
height: 200%;
transform: scale(.5, .5);
box-sizing: border-box;
transform-origin: 0 0;
}
}
.exm {
@include border_s(1px 0 1px);
}
方便复用,边框需求变幻
相关文章推荐
- CSS FILTERS:CSS过滤器能够做什么?
- CSS清除浮动常用方法小结 CSS clear both {overflow:auto;zoom:1;}
- 纯css实现菜单激活状态切换
- CSS之Transform
- 《CSS权威指南》学习记录——选择器
- 控制CSS样式
- css的小技巧
- css实现三角形原理
- 转载 css放大效果实现
- Web前端学习第十二天·fighting_使用CSS布局和定位(二)
- Dialog_ _dialog系统样式讲解 及 透明背景
- (一)CSS书写基础、背景、文字属性
- background-position的百分比是怎么计算定位的
- CSS3 过渡、2D变形、3D变形 20160527
- CSS3中clip属性
- css:before和after中的content属性
- CSS3-06 样式 5
- CSS隐藏文字以及以图代字( text-indent: 100%;)
- Word2010中如何设置多级编号 把默认标题的样式设置为带有多级编号
- CSS3属性之——filter