1px解决方案--集锦
没有废话,直接上代码
汇聚各种版本,持续更新中。。。。
1.sass
@charset "utf-8";
/**
* @module 背景与边框
* @description 为元素添加边框(包括1px边框)
* @method border
* @version 2.0.0
* @param {String} $border-width 指定边框厚度(单位为px),默认值:1px,取值与`border-width`属性一致,不同方向代表边框位置 <2.0.0>
* @param {String} $border-color 指定边框颜色 <2.0.0>
* @param {String} $border-style 指定边框样式 <2.0.0>
* @param {String} $radius 指定边框圆角半径,默认值:null <2.0.0>
*/
@mixin border($border-width: 1px, $border-color: map-get($base, border-color), $border-style: solid, $radius: null) {
// 为边框位置提供定位参考
position: relative;
@if $border-width == null {
$border-width:;
}
border-radius: $radius;
&::after {
// 用以解决边框layer遮盖内容
pointer-events: none;
position: absolute;
z-index:;
top:;
left:;
// fix当元素宽度出现小数时,边框可能显示不全的问题
// overflow: hidden;
content: "\0020";
border-color: $border-color;
border-style: $border-style;
border-width: $border-width;
// 适配dpr进行缩放
@include responsive(retina1x) {
width: 100%;
height: 100%;
@if $radius != null {
border-radius: $radius;
}
}
@include responsive(retina2x) {
width: 200%;
height: 200%;
@include transform(scale(.5));
@if $radius != null {
border-radius: $radius * 2;
}
}
@include responsive(retina3x) {
width: 300%;
height: 300%;
@include transform(scale(.33333));
@if $radius != null {
border-radius: $radius * 3;
}
}
@include transform-origin(0 0);
}
}
2.stylus
border($border-width = 1px, $border-color = #ccc, $border-style = solid, $radius = 0)
// 为边框位置提供定位参考
position: relative; if $border-width == null
$border-width: 0; border-radius: $radius; &::after
// 用以解决边框layer遮盖内容
pointer-events: none;
position: absolute;
z-index: 999;
top: 0;
left: 0;
// fix当元素宽度出现小数时,边框可能显示不全的问题
// overflow: hidden;
content: "\0020";
border-color: $border-color;
border-style: $border-style;
border-width: $border-width; // 适配dpr进行缩放
@media (max--moz-device-pixel-ratio: 1.49), (-webkit-max-device-pixel-ratio: 1.49), (max-device-pixel-ratio: 1.49), (max-resolution: 143dpi), (max-resolution: 1.49dppx)
width: 100%;
height: 100%;
if $radius != null {
border-radius: $radius;
} @media (min--moz-device-pixel-ratio: 1.5) and (max--moz-device-pixel-ratio: 2.49), (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 2.49),(min-device-pixel-ratio: 1.5) and (max-device-pixel-ratio: 2.49),(min-resolution: 144dpi) and (max-resolution: 239dpi),(min-resolution: 1.5dppx) and (max-resolution: 2.49dppx)
width: 200%;
height: 200%;
transform: scale(.5)
if $radius != null {
border-radius: $radius * 2;
} @media (min--moz-device-pixel-ratio: 2.5), (-webkit-min-device-pixel-ratio: 2.5),(min-device-pixel-ratio: 2.5), (min-resolution: 240dpi),(min-resolution: 2.5dppx)
width: 300%;
height: 300%;
transform: scale(.33333)
if $radius != null {
border-radius: $radius * 3;
} transform-origin: 0 0;
3.react组件中
import styled from 'styled-components'
const border = ({
component=null,
width='1px',
style='solid',
color='#ccc',
radius=0
}) => {
return styled(component) `
position: relative;
border-width: ${ width };
border-radius: ${ radius + 'px' };
&::after {
pointer-events: none;
position: absolute;
z-index: 999;
top: 0;
left: 0;
content: "";
border-color: ${ color };
border-style: ${ style };
border-width: ${ width };
@media
(max--moz-device-pixel-ratio: 1.49),
(-webkit-max-device-pixel-ratio: 1.49),
(max-device-pixel-ratio: 1.49),
(max-resolution: 143dpi),
(max-resolution: 1.49dppx) {
width: 100%;
height: 100%;
border-radius: ${ radius + 'px' };
};
@media
(min--moz-device-pixel-ratio: 1.5) and (max--moz-device-pixel-ratio: 2.49),
(-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 2.49),
(min-device-pixel-ratio: 1.5) and (max-device-pixel-ratio: 2.49),
(min-resolution: 144dpi) and (max-resolution: 239dpi),
(min-resolution: 1.5dppx) and (max-resolution: 2.49dppx) {
width: 200%;
height: 200%;
transform: scale(.5);
border-radius: ${ radius * 2 + 'px'};
};
@media
(min--moz-device-pixel-ratio: 2.5),
(-webkit-min-device-pixel-ratio: 2.5),
(min-device-pixel-ratio: 2.5),
(min-resolution: 240dpi),
(min-resolution: 2.5dppx) {
width: 300%;
height: 300%;
transform: scale(.33333);
border-radius: ${ radius * 3 + 'px' }
};
transform-origin: 0 0;
};
`
}
export default border
1px解决方案--集锦的更多相关文章
- Retina 屏移动设备 1px解决方案
做移动端H5页面开发时都会遇到这样的问题,用 CSS 定义 1px 的实线边框,在 window.devicePixelRatio=2 的屏幕上会显示成 2px,在 window.devicePix ...
- 【实用】【移动端】Retain屏1px解决方案
新浪微博HTML5版 微博的实现方式(rem + 小数px) <meta name="viewport" content="width=device-width,i ...
- Server Application Unavailable出现的原因及解决方案集锦
iis ServerAppl 共存 应用程序池 站点 在Asp.net站点中经常出现这种提示 Server Application Unavailable The web application y ...
- IIS网站打不开错误解决方案集锦(一):编译器错误消息: 编译器失败,错误代码为 -1073741502。
[2015-05-12解决记录] 问题:服务器上的文件一直都是好的,但是运行了很长一段时间以后,发现网站打不开,或者上传不了图片了,怎么办? 错误信息:c:\windows\system32\inet ...
- 演示demo开发问题及解决方案集锦
模型处理问题: 1. 3Dmax模型导入Unity单位设置: 自定义->单位设置->系统单位设置与显示单位比例都调成厘米 2. 3Dmax中材质贴图: 点击材质编辑器[在模式下可以选择精简 ...
- element ui 动态菜单解决方案集锦
1.<分享一个VUE Element-UI 的多级菜单动态渲染的组件> 2.<饿了么组件库,element-ui开发精美的后台管理系统系列之(一)开发伸缩菜单> 3.<V ...
- mobile web retina 下 1px 边框解决方案
本文实际上想说的是ios8下 1px解决方案. 1px的边框在devicePixelRatio = 2的retina屏下会显示成2px,在iphone 6 plug 下,更显示成3px.由其影响美感. ...
- 移动端1px细线解决方案总结
现在的PM和UI总以看app的眼光看html5, html页面要做的专业美观,而且必须很精细. 去年的时候UI就告诉我h5上的边框线太粗,把整站都给拉low了. 当时工期紧就没太在意1px粗细, 好在 ...
- 再谈mobile web retina 下 1px 边框解决方案
本文实际上想说的是ios8下 1px解决方案. 1px的边框在devicePixelRatio = 2的retina屏下会显示成2px,在iphone 6 plug 下,更显示成3px.由其影响美感. ...
随机推荐
- 常用邮箱POP3 STMP服务器与端口号设置
一.常用邮箱POP3 STMP服务器与端口号设置: [网易 163.126免费邮箱目前不直接开放smtp.pop3服务.有需要的用户可通过购买随身邮或邮箱伴侣及加入会员中心获得.从2006年11月16 ...
- 黑苹果,Win7,Win10,Xp 各个系统镜像文件下载地址(备用)
windows Mac Xp(系统镜像下载装系统专区)百度系统世家也可 http://www.xp933.com/download/ 黑苹果系统(各种驱动型号下载专区) http://www.it36 ...
- vue中使用vue-quill-editor及上传图片到自己服务器
第一步,下载依赖 cnpm install vue-quill-editor --save 第二步,再main.js里引入组件(我这里是全局注册) // 富文本编辑器 import VueQuillE ...
- java中xxe漏洞修复方法
java中禁止外部实体引用的设置方法不止一种,这样就导致有些开发者修复的时候采用的错误的方法 之所以写这篇文章是有原因的!最早是有朋友在群里发了如下一个pdf, 而当时已经是2019年1月末了,应该不 ...
- Js数组去重方法总结
//方法一 var arr = [1,23,1,1,1,3,23,5,6,7,9,9,8,5]; function removeDuplicatedItem(arr) { for(var i = 0; ...
- mac 配置vue+sanic环境准备工作
Vue用到npm/cnpm.webpack ,准备工作主要是将这些安装上. 首先安装这些最好使用root用户. 第一步安装npm:npm是node.js的一部分,所以需要安装node.js. 安装no ...
- parcel 在js中导入 html 文件
parcel不支持将html文件导入为字符串,如果您对parcel使用熟练,直接使用 parcel-plugin-phtml 插件即可,此插件使用 .phtml 后缀 为什么用parcel? 因为从我 ...
- Vue学习之路---No.3(分享心得,欢迎批评指正)
同样的,我们先来回顾一下昨天学习的内容: 1.利用v-once来组织双向绑定 2.filter{}过滤器的使用(详情请看上一章) 3.computed(计算属性),利用computed属性实现filt ...
- Linux内核开发进阶书籍推荐(不适合初学者)
Linux内核开发进阶书籍推荐(不适合初学者) 很早之前就想写一篇文章总结一下Linux Kernel开发的相关资料,项目的原因,再加上家里的一些事情,一直没能找到闲暇,今天终于有些时间,希望可以完成 ...
- gcc Build-in functions
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html gcc -posix -E -dM - </dev/null