Vue --- 引入reset.css和border.css文件

一、分别有reset.cssborder.css两个文件,我是放在了初始项目的assets文件夹下的;
引用方法如下
只需要在main.js里写入如下代码即可,当然路径按自己的实际情况来写

import './assets/reset.css'
import './assets/border.css'

Vue --- 引入reset.css和border.css文件_第1张图片

二、reset.css,初始化整体样式,去除某些标签的默认样式,比如

  • 的小黑点;
    因为每个人用的初始化样式都有所区别,但都大同小异,所以这里我只放我目前在用的代码,大家也可以自行搜索其他开发者发布的版本

    html, body, div, span, applet, object, iframe,
    h1, h2, h3, h4, h5, h6, p, blockquote, pre,
    a, abbr, acronym, address, big, cite, code,
    del, dfn, em, img, ins, kbd, q, s, samp,
    small, strike, strong, sub, sup, tt, var,
    b, u, i, center,
    dl, dt, dd, ol, ul, li,
    fieldset, form, label, legend,
    table, caption, tbody, tfoot, thead, tr, th, td,
    article, aside, canvas, details, embed, 
    figure, figcaption, footer, header, hgroup, 
    menu, nav, output, ruby, section, summary,
    time, mark, audio, video{
      margin: 0;
      padding: 0;
      border: 0;
      font-size: 100%;
      font: inherit;
      font-weight: normal;
      vertical-align: baseline;
    }
    /* HTML5 display-role reset for older browsers */
    article, aside, details, figcaption, figure, 
    footer, header, hgroup, menu, nav, section{
      display: block;
    }
    ol, ul, li{
      list-style: none;
    }
    blockquote, q{
      quotes: none;
    }
    blockquote:before, blockquote:after,
    q:before, q:after{
      content: '';
      content: none;
    }
    table{
      border-collapse: collapse;
      border-spacing: 0;
    }
     
    /* custom */
    a{
      color: #7e8c8d;
      text-decoration: none;
      -webkit-backface-visibility: hidden;
    }
    ::-webkit-scrollbar{
      width: 5px;
      height: 5px;
    }
    ::-webkit-scrollbar-track-piece{
      background-color: rgba(0, 0, 0, 0.2);
      -webkit-border-radius: 6px;
    }
    ::-webkit-scrollbar-thumb:vertical{
      height: 5px;
      background-color: rgba(125, 125, 125, 0.7);
      -webkit-border-radius: 6px;
    }
    ::-webkit-scrollbar-thumb:horizontal{
      width: 5px;
      background-color: rgba(125, 125, 125, 0.7);
      -webkit-border-radius: 6px;
    }
    html, body{
      width: 100%;
      font-family: "Arial", "Microsoft YaHei", "黑体", "宋体", "微软雅黑", sans-serif;
    }
    body{
      line-height: 1;
      -webkit-text-size-adjust: none;
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }
    html{
      overflow-y: scroll;
    }
     
    /*清除浮动*/
    .clearfix:before,
    .clearfix:after{
      content: " ";
      display: inline-block;
      height: 0;
      clear: both;
      visibility: hidden;
    }
    .clearfix{
      *zoom: 1;
    }
     
    /*隐藏*/
    .dn{
      display: none;
    }
    

    三、border.css,解决移动端1px边框的问题;
    某些高分辨率的手机会把你写好的1像素的边框给显示成2像素,所以需要使用该css来控制

    @charset "utf-8";
    .border,
    .border-top,
    .border-right,
    .border-bottom,
    .border-left,
    .border-topbottom,
    .border-rightleft,
    .border-topleft,
    .border-rightbottom,
    .border-topright,
    .border-bottomleft {
      position: relative;
    }
    .border::before,
    .border-top::before,
    .border-right::before,
    .border-bottom::before,
    .border-left::before,
    .border-topbottom::before,
    .border-topbottom::after,
    .border-rightleft::before,
    .border-rightleft::after,
    .border-topleft::before,
    .border-topleft::after,
    .border-rightbottom::before,
    .border-rightbottom::after,
    .border-topright::before,
    .border-topright::after,
    .border-bottomleft::before,
    .border-bottomleft::after {
      content: "\0020";
      overflow: hidden;
      position: absolute;
    }
    /* border
     * 因,边框是由伪元素区域遮盖在父级
     * 故,子级若有交互,需要对子级设置
     * 定位 及 z轴
     */
    .border::before {
      box-sizing: border-box;
      top: 0;
      left: 0;
      height: 100%;
      width: 100%;
      border: 1px solid #eaeaea;
      transform-origin: 0 0;
    }
    .border-top::before,
    .border-bottom::before,
    .border-topbottom::before,
    .border-topbottom::after,
    .border-topleft::before,
    .border-rightbottom::after,
    .border-topright::before,
    .border-bottomleft::before {
      left: 0;
      width: 100%;
      height: 1px;
    }
    .border-right::before,
    .border-left::before,
    .border-rightleft::before,
    .border-rightleft::after,
    .border-topleft::after,
    .border-rightbottom::before,
    .border-topright::after,
    .border-bottomleft::after {
      top: 0;
      width: 1px;
      height: 100%;
    }
    .border-top::before,
    .border-topbottom::before,
    .border-topleft::before,
    .border-topright::before {
      border-top: 1px solid #eaeaea;
      transform-origin: 0 0;
    }
    .border-right::before,
    .border-rightbottom::before,
    .border-rightleft::before,
    .border-topright::after {
      border-right: 1px solid #eaeaea;
      transform-origin: 100% 0;
    }
    .border-bottom::before,
    .border-topbottom::after,
    .border-rightbottom::after,
    .border-bottomleft::before {
      border-bottom: 1px solid #eaeaea;
      transform-origin: 0 100%;
    }
    .border-left::before,
    .border-topleft::after,
    .border-rightleft::after,
    .border-bottomleft::after {
      border-left: 1px solid #eaeaea;
      transform-origin: 0 0;
    }
    .border-top::before,
    .border-topbottom::before,
    .border-topleft::before,
    .border-topright::before {
      top: 0;
    }
    .border-right::before,
    .border-rightleft::after,
    .border-rightbottom::before,
    .border-topright::after {
      right: 0;
    }
    .border-bottom::before,
    .border-topbottom::after,
    .border-rightbottom::after,
    .border-bottomleft::after {
      bottom: 0;
    }
    .border-left::before,
    .border-rightleft::before,
    .border-topleft::after,
    .border-bottomleft::before {
      left: 0;
    }
    @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) {
      /* 默认值,无需重置 */
    }
    @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) {
      .border::before {
        width: 200%;
        height: 200%;
        transform: scale(.5);
      }
      .border-top::before,
      .border-bottom::before,
      .border-topbottom::before,
      .border-topbottom::after,
      .border-topleft::before,
      .border-rightbottom::after,
      .border-topright::before,
      .border-bottomleft::before {
        transform: scaleY(.5);
      }
      .border-right::before,
      .border-left::before,
      .border-rightleft::before,
      .border-rightleft::after,
      .border-topleft::after,
      .border-rightbottom::before,
      .border-topright::after,
      .border-bottomleft::after {
        transform: scaleX(.5);
      }
    }
    @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) {
      .border::before {
        width: 300%;
        height: 300%;
        transform: scale(.33333);
      }
      .border-top::before,
      .border-bottom::before,
      .border-topbottom::before,
      .border-topbottom::after,
      .border-topleft::before,
      .border-rightbottom::after,
      .border-topright::before,
      .border-bottomleft::before {
        transform: scaleY(.33333);
      }
      .border-right::before,
      .border-left::before,
      .border-rightleft::before,
      .border-rightleft::after,
      .border-topleft::after,
      .border-rightbottom::before,
      .border-topright::after,
      .border-bottomleft::after {
        transform: scaleX(.33333);
      }
    }
    

    你可能感兴趣的:(Vue)