zoukankan      html  css  js  c++  java
  • user agent stylesheet 浏览器默认样式

    今天在写一个网页的时候发现一个问题,我的table的样式很奇怪,也没有设置什么样式,跟其他的页面不一样,打开开发者工具一看,发现有这么点样式:

    其中右上角:user agent stylesheet

    1、user agent stylesheet是浏览器默认样式表,在写网页时,没有指定的样式,按浏览器内置的样式表来渲染。像word中也有一些预留样式,可以让我们的排版更美观整齐。

    2、不同浏览器甚至同一浏览器不同版本的默认样式是不同的。

    百度了一下,发现好多人都在初始化页面的样式,自己写样式覆盖默认,感觉这个办法不好;

    Google了一下,发现一个好办法:

    If <!DOCTYPE> is missing in your html you may experience that the browser gives preference to the "user agent stylesheet" over your custom stylesheet. Adding the doctype fixes this.

    所以在html顶部加上:

    <!DOCTYPE html>

    刷新发现OK了

     

  • 相关阅读:
    leetcode之Search in Rotated Sorted Array
    leetcode之Search Insert Position2
    leetcode之Search Insert Position
    二分查找之Search for a Range
    leetcode之Two Sum
    leetcode之Spiral Matrix II
    leetcode之Spiral Matrix
    杨辉三角
    周计划1[7.22~7.28]
    英美音的比较
  • 原文地址:https://www.cnblogs.com/Steven-shi/p/7941356.html
Copyright © 2011-2022 走看看