欢迎光临,了解微信小程序开发,就上易用通!

自用样式解决方案:使用一像素边框

发布:2018-01-25 09:05浏览: 来源:网络 作者:tianshu

import 'common.scss' 
在需要1px边框的元素样式的开头添加@include px-border(#color,(some_position));。 其中color为边框颜色,some_position中填入需要边框的方位(不填则默认为所有方向), 
例如:@include px-border(#000,(top,right));,将会生成上方和右方的黑色边框;@include px-border(#000);,将在四周生成黑色边框。 
使用任何你喜欢的构建工具或编辑器插件将.scss产出为.wxss。 
common.scss:

 

  1. // 1px border
  2. @mixin px-border($color,$border:all) {
  3. position: relative;
  4.  
  5. &:after {
  6. content: " ";
  7. position: absolute;
  8. top: 0;
  9. left: 0;
  10. @if $border == all {
  11. border: 1px solid $color;
  12. }
  13. @else {
  14. @each $member in $border{
  15. border-#{$member}: 1px solid $color;
  16. };
  17. }
  18. width: 200%;
  19. height: 200%;
  20. -webkit-transform: scale(0.5);
  21. transform: scale(0.5);
  22. @media (-webkit-min-device-pixel-ratio:2.5) {
  23. width: 300%;
  24. height: 300%;
  25. -webkit-transform: scale(.33333);
  26. transform: scale(.33333);
  27. }
  28. -webkit-transform-origin: 0 0;
  29. transform-origin: 0 0;
  30. box-sizing: border-box;
  31. }
  32. }




免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。