码迷,mamicode.com
首页 > Web开发 > 详细

css---ul的浏览器默认padding

时间:2017-12-03 00:30:34      阅读:682      评论:0      收藏:0      [点我收藏+]

标签:dir   sub   分享   order   weight   src   table   ora   答案   

  今天写代码碰到一个问题,将ul的list-style-type设置为none后,ul与外面的盒子之间总有一个距离。折腾了很久,最后将ul的padding设置为0后终于解决了这个问题。

  其代码如下:

  技术分享图片  技术分享图片

  结果最后显式如图:

  技术分享图片

  最后寻找到答案发现是HTML默认样式搞的鬼。既ul在IE、Firefox中都默认padding-left:40px(其他浏览器未测试)。

  为了防止以后再出类似问题,故查询了HTML和浏览器默认样式相关内容如下:

 

一HTML默认样式

  1. head { display: none }/*默认不显示*/
  2. body { margin: 8px; line-height: 1.12 }
  3. h1 { font-size: 2em; margin: .67em 0 }
  4. h2 { font-size: 1.5em; margin: .75em 0 }
  5. h3 { font-size: 1.17em; margin: .83em 0 }
  6. h4, p, blockquote, ul, fieldset, form, ol, dl, dir, menu { margin: 1.12em 0 }
  7. h5 { font-size: .83em; margin: 1.5em 0 }
  8. h6 { font-size: .75em; margin: 1.67em 0 }
  9. h1, h2, h3, h4, h5, h6, b,strong { font-weight: bolder }
  10. li { display: list-item }/*默认以列表显示*/
  11. ol, ul, dir, menu, dd { margin-left: 40px }
  12. ol { list-style-type: decimal }
  13. ol ul, ul ol, ul ul, ol ol { margin-top: 0; margin-bottom: 0 }

  表格部分:

  1. table { display: table }/*默认为表格显示*/
  2. tr { display: table-row }/*默认为表格行显示*/
  3. thead { display: table-header-group }/*默认为表格头部分组显示*/
  4. tbody { display: table-row-group }/*默认为表格行分组显示*/
  5. tfoot { display: table-footer-group }/*默认为表格底部分组显示*/
  6. col { display: table-column }/*默认为表格列显示*/
  7. colgroup { display: table-column-group }/*默认为表格列分组显示*/
  8. td, th { display: table-cell; }/*默认为单元格显示*/
  9. caption { display: table-caption }/*默认为表格标题显示*/
  10. th { font-weight: bolder; text-align: center }/*默认为表格标题显示,呈现加粗居中状态*/
  11. caption { text-align: center }/*默认为表格标题显示,呈现居中状态*/
  12. table { border-spacing: 2px; }
  13. thead, tbody, tfoot { vertical-align: middle }/*定义表头、主体表、表脚元素默认为垂直对齐*/
  14. td, th { vertical-align: inherit }/*定义单元格、列标题默认为垂直对齐默认为继承*/

  其他:

  1. blockquote { margin-left: 40px; margin-right: 40px }
  2. i, cite, em,var, address { font-style: italic }
  3. pre, tt, code, kbd, samp { font-family: monospace }
  4. pre { white-space: pre }
  5. button, textarea, input, object, select { display:inline-block; }
  6. big { font-size: 1.17em }
  7. small, sub, sup { font-size: .83em }
  8. sub { vertical-align: sub }/*定义sub元素默认为下标显示*/
  9. sup { vertical-align: super }/*定义sub元素默认为上标显示*/
  10. s, strike, del { text-decoration: line-through }/*定义这些元素默认为删除线显示*/
  11. hr { border: 1px inset }/*定义分割线默认为1px宽的3D凹边效果*/
  12. u, ins { text-decoration: underline }
  13. br:before { content: ""A" }/*定义换行元素的伪对象内容样式*/
  14. :before, :after { white-space: pre-line }/*定义伪对象空格字符的默认样式*/
  15. center { text-align: center }
  16. abbr, acronym { font-variant: small-caps; letter-spacing: 0.1em }
  17. :link, :visited { text-decoration: underline }
  18. :focus { outline: thin dotted invert }
  19. /* Begin bidirectionality settings (do not change) */
  20. BDO[DIR="ltr"] { direction: ltr; unicode-bidi: bidi-override }/*定义BDO元素当其属性为DIR="ltr"时的默认文本读写显示顺序*/
  21. BDO[DIR="rtl"] { direction: rtl; unicode-bidi: bidi-override }/*定义BDO元素当其属性为DIR="rtl"时的默认文本读写显示顺序*/
  22. *[DIR="ltr"] { direction: ltr; unicode-bidi: embed }/*定义任何元素当其属性为DIR="ltr"时的默认文本读写显示顺序*/
  23. *[DIR="rtl"] { direction: rtl; unicode-bidi: embed }/*定义任何元素当其属性为DIR="rtl"时的默认文本读写显示顺序*/
  24. @media print { /*定义标题和列表默认的打印样式*/
  25. h1 { page-break-before: always }
  26. h1, h2, h3, h4, h5, h6 { page-break-after: avoid }
  27. ul, ol, dl { page-break-before: avoid }

 

二、浏览器默认样式

  页边距:

  1. IE默认为10px,通过body的margin属性设置
  2. FF默认为8px,通过body的padding属性设置

  段间距:

  1. IE默认为19px,通过p的margin-top属性设置
  2. FF默认为1.12em,通过p的margin-bottom属性设

  标题样式:

  1. h1~h6默认加粗显示:font-weight:bold;。

  列表样式:

  1. IE默认为40px,通过ul、ol的margin属性设置
  2. FF默认为40px,通过ul、ol的padding属性设置
  3. dl无缩进,但起内部的说明元素dd默认缩进40px,而名称元素dt没有缩进。

  元素居中

  1. IE默认为text-align:center;
  2. FF默认为margin-left:auto;margin-right:auto;

  超链接样式

  1. a 样式默认带有下划线,显示颜色为蓝色,被访问过的超链接变紫色

  鼠标样式

  1. IE默认为cursor:hand;
  2. FF默认为cursor:pointer;。该声明在IE中也有效

  图片链接样式

  1. IE默认为紫色2px的边框线
  2. FF默认为蓝色2px的边框线

css---ul的浏览器默认padding

标签:dir   sub   分享   order   weight   src   table   ora   答案   

原文地址:http://www.cnblogs.com/huanqna/p/7953931.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!