CSS常用样式修正(含部分问题兼容)1.0版

前些天总结的目前在学习开发中常遇到的移动端的普通样式的总结 

免得我老是复写 ,或者是老是要找半天的资料

/* 初始化 */
body, div, ul, li, ol, h1, h2, h3, h4, h5, h6, input, textarea, select, p, dl, dt, dd, a, img, button, form, table, th, tr, td, tbody, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  margin: 0;
  padding: 0;
}
/* 字体统一微软雅黑 */
body {
  font: 12px/1.5 'Microsoft YaHei','宋体', Tahoma, Arial, sans-serif;
  color: #555;
  background-color: #F7F7F7;
}
/* 字体样式为普通 */
em, i {
  font-style: normal;
}
ul,li,ol{
  list-style-type: none;
  list-style: none;
}
strong {
  font-weight: normal;
}
.clearfix:after {
  content: "";
  display: block;
  visibility: hidden;
  height: 0;
  clear: both;
}
.clearfix {
  zoom: 1;
}
/* 修正触发样式 */
a:active,
a:hover {
  outline-width: 0;
}
a {
  text-decoration: none;
  color: #969696;
  font-family: 'Microsoft YaHei', Tahoma, Arial, sans-serif;
  background-color: transparent; /* 1 */
  -webkit-text-decoration-skip: objects; /* 2 */
  text-decoration: none;
}
a:hover {
  text-decoration: none;
}
/* 移动端点击a链接出现蓝色背景问题解决 */
a:link,a:active,a:visited,a:hover {
  background: none;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-tap-highlight-color: transparent;
}
/* 标题字体大小设置 */
h1, h2, h3, h4, h5, h6 {
  font-size: 100%;
  font-family: 'Microsoft YaHei';
}
input{
  font-family: 'Microsoft YaHei';
}
button,input,optgroup,select,
textarea {
     font-family: sans-serif; /* 1 */
     font-size: 100%; /* 1 */
     line-height: 1.15; /* 1 */
     margin: 0; /* 2 */
}
/* 响应边框清除 */
button,input { /* 1 */
    overflow: visible;
    outline-style: none;
}
/* 禁止缩放表单 */
input[type="submit"], input[type="reset"], input[type="button"], input {
    resize: none;
    border: none;
}
/* 取消链接高亮  */
body, div, ul, li, ol, h1, h2, h3, h4, h5, h6, input, textarea, select, p, dl, dt, dd, a, img, button, form, table, th, tr, td, tbody, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
/* 图片自适应 */
img {
  width: 100%;
  height: auto;
  width: auto\9; /* ie8 */
  display: block;
  -ms-interpolation-mode: bicubic;/*为了照顾ie图片缩放失真*/
  border: none;/*边框清除*/
}
/*基本文档模块----------------------------------------------*/
   html {
    font-family: sans-serif; /* 1 */
    line-height: 1.15; /* 2 */
    -ms-text-size-adjust: 100%; /* 3 */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    /* 解决IOS默认滑动不流畅 */
    -webkit-overflow-scrolling : touch;
  }
  
  /* 内容模块------------------------------------------------------ */
  /* 设置HTML5元素为块 */
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  display: block;
}
  /**
   * 在 IE 8 中添加边距。
   */
  
  figure {
    margin: 1em 40px;
  }
  /* 在火狐中正确显示hr  Edge和IE中显示溢出 */
  
  hr {
    box-sizing: content-box; /* 1 */
    height: 0; /* 1 */
    overflow: visible; /* 2 */
  }
  
  /**
   * 1. 更正所有浏览器中字体大小的继承和缩放。
   * 2. 更正所有浏览器中对应类字体大小。
   */
   code,
   kbd,
   samp {
     font-family: monospace, monospace; /* 1 */
     font-size: 1em; /* 2 */
   }
    pre {
    font-family: monospace, monospace; /* 1 */
    font-size: 1em; /* 2 */
  } 
  /**
   * 1. 清除响应按钮边框 Firefox 39-.
   * 2. 添加边框样式 Chrome, Edge, IE, Opera, Safari.
   */
  
  abbr[title] {
    border-bottom: none; /* 1 */
    text-decoration: underline; /* 2 */
    text-decoration: underline dotted; /* 2 */
  }
  /**
   * 在安卓中添加正确的字体样式 4.3-.
   */
  
   dfn {
    font-style: italic;
  }
  /**
   * 防止复用“粗体”。
   */
  
  b,
  strong {
    font-weight: inherit;
  }
  
  /**
   * 在边边和 Safari 浏览器中添加默认的字体粗细。
   */
  
  b,
  strong {
    font-weight: bolder;
  }
  
  /**
   * 在所有浏览器中添加默认的字体大小
   */
  
  small {
    font-size: 80%;
  }
  
  /**
   * 防止“sub”和“sup”元素在浏览器的影响(自己常用的大家看着来啊)
   */
  
  sub,
  sup {
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
  }
  
  sub {
    bottom: -0.25em;
  }
  
  sup {
    top: -0.5em;
  }
  
  /* 元素内容------------------------------------------------------------------ */
  
  /**
   * 统一样式 IE 9-.
   */
  
  audio,
  video {
    display: inline-block;
  }
  
  /**
   * iOS统一样式 iOS 4-7.
   */
  
  audio:not([controls]) {
    display: none;
    height: 0;
  }
  
  /**
   * 清除边框 IE 10-.
   */
  
  img {
    border-style: none;
  }
  
  /**
   * Hide the overflow in IE.
   */
  
  svg:not(:root) {
    overflow: hidden;
  }
  
  /* 表单---------------------------------------------------------------- */
  /* 清除文本转换继承权 */
  button,
  select { /* 1 */
    text-transform: none;
  }
  /* 修正ios和相对应浏览器无法点击的问题 */
  button,
  html [type="button"], /* 1 */
  [type="reset"],
  [type="submit"] {
    -webkit-appearance: button; /* 2 */
  }
  /* 删除火狐内边框的焦点和填充 */
  button::-moz-focus-inner,
  [type="button"]::-moz-focus-inner,
  [type="reset"]::-moz-focus-inner,
  [type="submit"]::-moz-focus-inner {
    border-style: none;
    padding: 0;
  }
  /* 修正火狐搜索框的外观 */
  button:-moz-focusring,
  [type="button"]:-moz-focusring,
  [type="reset"]:-moz-focusring,
  [type="submit"]:-moz-focusring {
    outline: 1px dotted ButtonText;
  }
  
  /**
   * 修正所有浏览器中的边框、边距和填充(固有)。
   */
  
  fieldset {
    border: 1px solid #c0c0c0;
    margin: 0 2px;
    padding: 0.35em 0.625em 0.75em;
  }
  
  /**
   * 1. 修正边缘和 IE 中的文本换行。
   * 2. 修正IE 中“字段集”元素的颜色继承。
   * 3. 删除填充,以便开发人员在归零时不会被发现
   * 所有浏览器中的“字段集”元素。(老浏览器的添不添都行)
   */
  
  legend {
    box-sizing: border-box; /* 1 */
    color: inherit; /* 2 */
    display: table; /* 1 */
    max-width: 100%; /* 1 */
    padding: 0; /* 3 */
    white-space: normal; /* 1 */
  }
  
  /**
   * 1. 在 IE 9- 中添加正确的显示.
   * 2. 在火狐和谷歌中添加正确的垂直对齐方式。
   */
  
  progress {
    display: inline-block; /* 1 */
    vertical-align: baseline; /* 2 */
  }
  
  /**
   * 删除 IE 中的默认垂直滚动条。
   */
  
  textarea {
    overflow: auto;
  }
  
  /**
   * 1. 在 IE 10- 中添加正确的框大小。
   * 2. 删除 IE 10- 中的填充。
   */
  
  [type="checkbox"],
  [type="radio"] {
    box-sizing: border-box; /* 1 */
    padding: 0; /* 2 */
  }
  
  /**
   * 修正 Chrome 中递增和递减按钮的光标样式。
   */
  
  [type="number"]::-webkit-inner-spin-button,
  [type="number"]::-webkit-outer-spin-button {
    height: auto;
  }
  
  /**
   * 1. 修正以前老旧的外观 Chrome and Safari.
   * 2. iphone及ipad下输入框默认内阴影
   */
  
  [type="search"] {
    -webkit-appearance: none; /* 1 */
    outline-offset: -2px; /* 2 */
  }
  
  /**
   * 在 macOS 上移除浏览器和 Safari 浏览器中的内侧填充和取消按钮
   */
  
  [type="search"]::-webkit-search-cancel-button,
  [type="search"]::-webkit-search-decoration {
    -webkit-appearance: none;
  }
  
  /**
   * 1.更正无法在 iOS 和 Safari 浏览器中设置可点击类型样式的问题。
   * 2. 在 Safari 浏览器中将字体属性更改为“继承”。
   */
  
  ::-webkit-file-upload-button {
    -webkit-appearance: button; /* 1 */
    font: inherit; /* 2 */
  }
  /*
   * 在所有浏览器中添加正确的显示。
   */
  
  summary {
    display: list-item;
  }
  canvas {
    display: inline-block;
  }
  template {
    display: none;
  }
  /* 浮动修正------------------------------------------------------------- */
  
  [hidden] {
    display: none;
  }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码到无能为力

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值