搜索
首页web前端H5教程Html5的Reset和Base样式结合的示例代码

结合Normalize CSS,Reset CSS, Base CSS, Html5 Reset Css整理了一份新的样式,我这里暂把他叫做HTML5 的Reset CSS 和Base CSS的结合。下面把相应的代码贴出来以供大家一起探讨。

/**
*Remove Spacing
*/body,dl,dd,ul,ol,figure ,h1,h2,h3,h4,h5,h6,p,pre,blockquote,
form ,fieldset,legend ,input,button,select,textarea {  margin: 0;  padding: 0;
}/*
 * Add block display for HTML5 elements
 * Corrects block display not defined in IE6/7/8/9 & FF3
 */article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section {  display: block;
}/* =============================================================================
   Typography
   ========================================================================== *//*
 * Add bottom border
 * Corrects styling not present in IE7/8/9 S5 Chrome
 */abbr[title],
dfn[title] {  border-bottom: 1px dotted;  cursor:help;
}/*
 * Define font family as monospace
 * Corrects font family set oddly in IE6 S5 C10
 * en.wikipedia.org/wiki/User:Davidgothberg/Test59
 */pre,
code,
kbd,
samp { font-family: monospace, sans-serif;   _font-family: 'Courier New', monospace, sans-serif; font-size: 1em;
}/*
 * Add line wrapping
 * Improves readability of pre-formatted text in all browsers
 */pre {  white-space: pre;/*CSS2*/
  white-space: pre-wrap;/*CSS2.1*/
  white-space: pre-line;/*CSS3*/
  word-wrap: break-word;/*IE*/}/*
 * Remove quotes
 * 1. Addresses CSS quotes not supported in IE6/7
 * 2. Addresses quote attributes not supported in S4
 */blockquote,
q {  quotes: none;
}
 
blockquote:before,
blockquote:after,
q:before,
q:after {  content: '';  content: none;
}/*
 * Define font size
 * Improves appearance in all browsers
 */small {  font-size: 75%;
}/*
 * Define font size and alignment
 * Improves appearance without affecting line-height in all browsers
 * gist.github.com/413930
 */sub,
sup {  font-size: 75%;  line-height: 0;  position: relative;  vertical-align: baseline;
}
 
sup {  top: -0.5em;
}
 
sub {  bottom: -0.25em;
}/*Clear floats 
 *The Magnificent CLEARFIX:Updated fo prevent margin-collapsing on child elements 
 */.clearfix:before,
.clearfix:after {   content:"\0020";   display: block;   height: 0;   visibility: hidden;
}
 
.clearfix {  zoom: 1;/*IE<8*/}
 
.clearfix:after {  clear: both;
}
* html .clearfix { 
  zoom: 1; /* IE6 */} 
*:first-child+html .clearfix { 
  zoom: 1; /* IE7 */} 
 
/*
 * Add inline-block display for HTML5 elements
 * Corrects inline-block display not defined in IE6/7/8/9 & FF3
 */audio[controls],
canvas,
video { display: inline-block;
 *display: inline;
 *zoom: 1;
}
 
html { font-size: 100.01%;/*To Prevent bugs in IE and Opera*/
 height: 100%;/*Using height 100% on html and body allows to style containers with a 100% height*/
 overflow-y: scroll;/*The overflow declaration is to make sure there is a gutter for the scollbar in all browsers regardless of content*/
 cursor: default; /* Add normal cursor  Improves visual focus of page during mouse use in all browsers */
 overflow-y: scroll; /* Add vertical scrollbar  Keeps page centered in all browsers regardless of content height */
 -webkit-tap-highlight-color: transparent; /* Add vertical scrollbar  Keeps page centered in all browsers regardless of content height */
 -ms-text-size-adjust: 100%; /* Define maximum text display as 100% to document Corrects text displayed oddly after orientation change in handheld browsers */
 -webkit-text-size-adjust: 100%; /* Define maximum text display as 100% to document Corrects text displayed oddly after orientation change in handheld browsers */}
 
body { background-color: #fff;/*Not all browsers set white as the default background color*/
 color: #444;/*#444 looks better than black*/
 height: 100%;
}
 
body,
button
input,
select,
textarea { font: 12px/1.5 sans-serif;
}
 
img,fieldset {  border: 0 none; /*Remove border   Improves readability when inside <a> element in all browsers*/}
 
img {  vertical-align: top;  -ms-interpolation-mode: bicubic; /*Add high quality bicubic image resampling Improves visual appearance when scaled in IE7*/}/* =============================================================================
   Links
   ========================================================================== *//*
 * Remove outline
 * Improves appearance when active or hovered in all browsers
 * people.opera.com/patrickl/experiments/keyboard/test
 */a,
a:active,
a:hover {  outline: none;
}/*
 * Define outline as thin dotted
 * Improves appearance displayed oddly in C10
*/a:focus { outline: thin dotted;
}
 
a,
a:link { color: #0000EE; text-decoration: none;
}
 
a:hover { text-decoration: underline;
}
a:visited {  text-decoration: none;  color: #551A8B;
}/*Hide only visually,but have it available for screenreaders*/.hidden {   border: 0 !important;   clip: rect(1px 1px 1px 1px);/*IE<8*/
   clip: rect(1px,1px,1px,1px);   height: 1px !important;   margin: -1px;   overflow: hidden;   padding: 0 !important;   position: absolute !important;   width: 1px;
}/* =============================================================================
   Lists
   ========================================================================== */dd {  margin: 0 0 0 40px;
}
 
nav ul,
nav ol {  list-style: none;
}/* =============================================================================
   Forms
   ========================================================================== */form {  overflow: visible;
}
 
fieldset {  line-height: 1;/*line height helps to set the vertical alignment of radio buttons and check boxes*/}/*
 * Add negative left margin
 * Corrects alignment displayed oddly in IE6/7
 */legend {
  *margin-left: -7px;
}/*
 * Define consistent vertical alignment display in all browsers
 */button,
input,
select,
textarea {  vertical-align: baseline; 
  *vertical-align: middle; 
}/*
 * 1. Define line-height as normal
 *    Corrects FF3/4 setting it using !important in the UA stylesheet
 * 2. Make visible overflow
 *    Fixes spacing displayed oddly in IE6/7
 */button,
input {  line-height: normal; /* 1 */
  *overflow: visible;  /* 2 */}/*
 * 1. Display hand cursor for clickable form elements
 *    Improves usability and consistency of cursor style between image-type <input /> and others
 * 2. Define appearance for clickable form elements
 *    Corrects inability to style clickable <input /> types in iOS
 */button,
input[type="button"], 
input[type="reset"], 
input[type="submit"],
.form-btn,
.btn {  cursor: pointer; /* 1 */
  -webkit-appearance: button; /* 2 */}/*
 * Define box sizing
 * Addresses box sizing set to content-box in IE8/9
 */input[type="checkbox"],
input[type="radio"] {  box-sizing: border-box;
}
 
input[type="checkbox"] {  vertical-align: bottom;/*Vertical alignment of checkboxes*/
  *vertical-align: baseline;/*IE7*/}
 
input[type="radio"] {  vertical-align: text-bottom;/*Vertical alignment of radio buttons*/}
 
input {  _vertical-align: text-bottom;/*Vertical alignment of input fields for IE6*/}/*
 * Define box sizing and appearance
 * Addresses box sizing set to border-box in S5 Chrome (include -moz to future-proof)
 * Addresses appearance set to searchfield in S5 Chrome
 */input[type="search"] {  -webkit-appearance: textfield;  -moz-box-sizing: content-box;  -webkit-box-sizing: content-box;  box-sizing: content-box;
}/*
 * Remove inner padding and border
 * Fixes appearance displayed oddly in FF3/4
 * www.sitepen.com/blog/2008/05/14/the-devils-in-the-details-fixing-dojos-toolbar-buttons/
 */button::-moz-focus-inner,
input::-moz-focus-inner {  border: 0;  padding: 0;
}/*
 * 1. Disable default vertical scrollbar
 *    Corrects scrollbar displayed oddly in IE6/7/8/9
 * 2. Add top vertical alignment
 *    Improves readability and aligment in all browsers
 */textarea {  overflow: auto; /* 1 */
  vertical-align: top; /* 2 */}
 
input[type="email"],
input[type="text"],
input[type="password"],
input[type="select"],
input[type="search"],
input[type="file"],
textarea,
select {  -moz-border-radius: 3px;  -webkit-border-radius: 3px;  border-radius: 3px;  border: 1px solid #7F9DB9;
}
 
input:focus,
textarea:focus,
select:focus {  outline-width: 0;/*No outline border for Safary*/}
 
 
select {  background-color: transparent;/*In Webkit/Mac, select fails to inherit color,font-*,etc if there is no other styling like background for example(border will do to)*/}
 
label {  font-weight: normal;
}
 
label.required:after { 
  content:"*";  color:red;  font-family:"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;
}
 
button,
input[type="submit"],
input[type="reset"],
input[type="button"],
.form-btn {  width: auto;
  *width: 1;  overflow: visible;
}/* =============================================================================
   Tables
   ========================================================================== *//* 
 * Remove spacing between table cells
 * Improves vertical and horizontal alignment in all browsers
 */table {  border-collapse: collapse;  border-spacing: 0;
}
 
th,
td {  padding: 0;  text-align: left;  vertical-align: middle;
}/*
 *Header
 */h1 {  font-size: 2em;
}
 
h2 {  font-size: 1.5em;
}
 
h3 {  font-size: 1.17em;
}
 
h4 {  font-size: 1em;
}
 
h5 {  font-size: 0.83em;
}
 
h6 {  font-size: 0.67em;
} 
 
p {  margin-bottom: 4px;
}

以上是Html5的Reset和Base样式结合的示例代码的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
H5:网络开发的新功能和功能H5:网络开发的新功能和功能Apr 29, 2025 am 12:07 AM

H5带来了多项新功能和能力,极大提升了网页的互动性和开发效率。1.语义化标签如、增强了SEO。2.多媒体支持通过和标签简化了音视频播放。3.Canvas绘图提供了动态图形绘制工具。4.本地存储通过localStorage和sessionStorage简化了数据存储。5.地理位置API便于开发基于位置的服务。

H5:HTML5的关键改进H5:HTML5的关键改进Apr 28, 2025 am 12:26 AM

HTML5带来了五个关键改进:1.语义化标签提升了代码清晰度和SEO效果;2.多媒体支持简化了视频和音频嵌入;3.表单增强简化了验证;4.离线与本地存储提高了用户体验;5.画布与图形功能增强了网页的可视化效果。

HTML5:标准及其对Web开发的影响HTML5:标准及其对Web开发的影响Apr 27, 2025 am 12:12 AM

HTML5的核心特性包括语义化标签、多媒体支持、离线存储与本地存储、表单增强。1.语义化标签如、等,提升代码可读性和SEO效果。2.和标签简化多媒体嵌入。3.离线存储和本地存储如ApplicationCache和LocalStorage,支持无网络运行和数据存储。4.表单增强引入新输入类型和验证属性,简化处理和验证。

H5代码示例:实际应用和教程H5代码示例:实际应用和教程Apr 25, 2025 am 12:10 AM

H5提供了多种新特性和功能,极大地增强了前端开发的能力。1.多媒体支持:通过和元素嵌入媒体,无需插件。2.画布(Canvas):使用元素动态渲染2D图形和动画。3.本地存储:通过localStorage和sessionStorage实现数据持久化存储,提升用户体验。

H5和HTML5之间的连接:相似性和差异H5和HTML5之间的连接:相似性和差异Apr 24, 2025 am 12:01 AM

H5和HTML5是不同的概念:HTML5是HTML的一个版本,包含新元素和API;H5是基于HTML5的移动应用开发框架。HTML5通过浏览器解析和渲染代码,H5应用则需要容器运行并通过JavaScript与原生代码交互。

H5代码的基础:密钥元素及其目的H5代码的基础:密钥元素及其目的Apr 23, 2025 am 12:09 AM

HTML5的关键元素包括、、、、、等,用于构建现代网页。1.定义头部内容,2.用于导航链接,3.表示独立文章内容,4.组织页面内容,5.展示侧边栏内容,6.定义页脚,这些元素增强了网页的结构和功能性。

HTML5和H5:了解常见用法HTML5和H5:了解常见用法Apr 22, 2025 am 12:01 AM

HTML5和H5没有区别,H5是HTML5的简称。1.HTML5是HTML的第五个版本,增强了网页的多媒体和交互功能。2.H5常用于指代基于HTML5的移动网页或应用,适用于各种移动设备。

HTML5:现代网络的基础(H5)HTML5:现代网络的基础(H5)Apr 21, 2025 am 12:05 AM

HTML5是超文本标记语言的最新版本,由W3C标准化。HTML5引入了新的语义化标签、多媒体支持和表单增强,提升了网页结构、用户体验和SEO效果。HTML5引入了新的语义化标签,如、、、等,使网页结构更清晰,SEO效果更好。HTML5支持多媒体元素和,无需第三方插件,提升了用户体验和加载速度。HTML5增强了表单功能,引入了新的输入类型如、等,提高了用户体验和表单验证效率。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具