没有废话,直接上代码

汇聚各种版本,持续更新中。。。。

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解决方案--集锦的更多相关文章

  1. Retina 屏移动设备 1px解决方案

    做移动端H5页面开发时都会遇到这样的问题,用 CSS 定义 1px 的实线边框,在 window.devicePixelRatio=2  的屏幕上会显示成 2px,在 window.devicePix ...

  2. 【实用】【移动端】Retain屏1px解决方案

    新浪微博HTML5版 微博的实现方式(rem + 小数px) <meta name="viewport" content="width=device-width,i ...

  3. Server Application Unavailable出现的原因及解决方案集锦

    iis ServerAppl 共存 应用程序池 站点  在Asp.net站点中经常出现这种提示 Server Application Unavailable The web application y ...

  4. IIS网站打不开错误解决方案集锦(一):编译器错误消息: 编译器失败,错误代码为 -1073741502。

    [2015-05-12解决记录] 问题:服务器上的文件一直都是好的,但是运行了很长一段时间以后,发现网站打不开,或者上传不了图片了,怎么办? 错误信息:c:\windows\system32\inet ...

  5. 演示demo开发问题及解决方案集锦

    模型处理问题: 1. 3Dmax模型导入Unity单位设置: 自定义->单位设置->系统单位设置与显示单位比例都调成厘米 2. 3Dmax中材质贴图: 点击材质编辑器[在模式下可以选择精简 ...

  6. element ui 动态菜单解决方案集锦

    1.<分享一个VUE Element-UI 的多级菜单动态渲染的组件> 2.<饿了么组件库,element-ui开发精美的后台管理系统系列之(一)开发伸缩菜单> 3.<V ...

  7. mobile web retina 下 1px 边框解决方案

    本文实际上想说的是ios8下 1px解决方案. 1px的边框在devicePixelRatio = 2的retina屏下会显示成2px,在iphone 6 plug 下,更显示成3px.由其影响美感. ...

  8. 移动端1px细线解决方案总结

    现在的PM和UI总以看app的眼光看html5, html页面要做的专业美观,而且必须很精细. 去年的时候UI就告诉我h5上的边框线太粗,把整站都给拉low了. 当时工期紧就没太在意1px粗细, 好在 ...

  9. 再谈mobile web retina 下 1px 边框解决方案

    本文实际上想说的是ios8下 1px解决方案. 1px的边框在devicePixelRatio = 2的retina屏下会显示成2px,在iphone 6 plug 下,更显示成3px.由其影响美感. ...

随机推荐

  1. fastjson JSONObject遍历

    private static String getDesc(String jsonStr, String key) { JSONObject jsonObject = JSONObject.parse ...

  2. webpack(5) -开发环境

    使用 source map (仅用于开发环境) 当 webpack 打包源代码时,可能会很难追踪到 error(错误) 和 warning(警告) 在源代码中的原始位置.例如,如果将三个源文件(a.j ...

  3. 两种库解析、构造 JSON

    1.用CJSON库 1.1解析Json 需要解析的JSON文件: { "name":"Tsybius", , "sex_is_male":t ...

  4. Oracle 10053

    [10053]alter session set events '10053 trace name context forever,level 1'; <Run your SQL here;&g ...

  5. 2019-oo-第二次总结

    这一单元是关于模拟电梯运行,考验多线程的一个单元,难度由简入入深,从多线程单部电梯,到优化,再到多线程多部电梯,难度一次次的提高. 一.多线程单部电梯(傻瓜调度) 1.设计策略 这一次我只额外的开了一 ...

  6. 关于微信跳转,这里有你想知道的一切weixin://dl/business/?ticket=td9cd0bf056c561fe9f56e33c61df61bf

    纠结了了很久,还是放出来部分接口,相信能够看到这篇文章的人也基本都是需求比较强烈的. 京东: https://wq.jd.com/mjgj/link/GetOpenLink?rurl=http%3a% ...

  7. vue中使用vue-quill-editor及上传图片到自己服务器

    第一步,下载依赖 cnpm install vue-quill-editor --save 第二步,再main.js里引入组件(我这里是全局注册) // 富文本编辑器 import VueQuillE ...

  8. 排序之冒泡排序(bubblesort)

    package com.pailian; /* * 冒泡排序 * 比较相邻的俩位数,这样每轮比较都会出现一个最大值或最小值 * 下一轮比较就会减少一次(因为已经知道了一个最大值或最小值) * 注意根据 ...

  9. spring boot + vue + element-ui全栈开发入门——spring boot后端开发

    前言 本文讲解作为后端的spring boot项目开发流程,如果您还不会配置spring boot环境,就请点击<玩转spring boot——快速开始>,如果您对spring boot还 ...

  10. sitecore8.2 如何关闭性能计数器

    在Sitecore.config文件或补丁文件修改Counters.Enabled为false值,此key默认为true;然后再修改Sitecore.Tasks.CounterDumpAgent 时间 ...