`
taro
  • 浏览: 135570 次
  • 性别: Icon_minigender_1
  • 来自: 东京
社区版块
存档分类
最新评论

css学习笔记(2) Reset CSS,clearfix

    博客分类:
  • CSS
阅读更多

一,Reset CSS

目的:减少各种浏览器下默认样式的差异。 

方法:

  1. 使用Reset CSS清除浏览器默认样式,网上有很多写好的Reset CSS模板,选一个适合自己网页要求的,复制黏贴。
  2. 写一个适合自己的Base CSS
/* =====================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: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	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;
}

/* ========================================== */
 

参考链接:http://meyerweb.com/eric/tools/css/reset/index.html; 

http://apps.hi.baidu.com/share/detail/16981702

 

 

二,clearfix(清除浮动)

     css中有个头疼的东西:布局。 使用float可能会带出很多排版上的错误,这时就可以利用clearfix来清除多余的float影响。

 解决办法:

  1. 在css文件中复制黏贴以下clearfix代码;
/* ========================= clearfix =============================== */
/* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */

.clearfix:before,
.clearfix:after{
	content: '.';
	display: block;
	overflow: hidden;
	visibility: hidden;
	font-size: 0;
	line-height: 0;
	width: 0;
	height: 0;
}

.clearfix:after{
	clear: both;
}

/*
	The following zoom:1 rule is specifically for IE6 + IE7.
	Move to separate stylesheet if invalid CSS is a problem.
*/

.clearfix{
	zoom: 1;
}

 

2.   在使用float:left 或者 float:right的HTML标签上调用clearfix

<div id="wraper" class="clearfix">

 

参考链接:http://www.cnblogs.com/zllwebjs/archive/2010/03/19/1689980.html

分享到:
评论

相关推荐

    浅谈css清除浮动(clearfix和clear)的用法

    本文主要是讲解如何在 html 中使用 clearfix 和 clear,针对那些刚开始了解 css 的童鞋。关于 clearfix 和 clear 的样式在这里我就不写了。 下面就谈谈对于这两个 class 的用法,首先我们先看个例子: XML/HTML Code...

    WEB标准之CSS 打造自己的reset.css

    reset.css本意就是重置样式,我始终建议把.clearfix放入layout.css,而把h1、h2之类的定义放进typography.css。 具体如何规划网站CSS结构,不在文本讨论之列,可以参考Smashing Magazine上的文章,国内有差强人意的...

    css之clearfix的用法深入理解(必看篇)

    如果有一个DIV作为外部容器,内部的DIV如果设置了float样式,则外部的容器DIV因为内部没有 clear,导致不能被撑开。看下面的例子:Div布局如下... .inner2{width:200px; height:200px; float:left; border:1px soli

    css中clearfix清除浮动的用法及其原理示例介绍

    大家对css中clearfix并不陌生吧,它的作用就是清除浮动,下面对clearfix的定义及实现原理简要的为大家做个介绍,另外还有个不错的示例,喜欢的朋友不要错过

    编写适合所有项目的通用的reset.css

    本文就是来介绍如何写一个合适所有项目的...reset.css本意就是重置样式,我始终建议把.clearfix放入layout.css,而把h1、h2之类的定义放进typography.css。 具体如何规划网站CSS结构,不在文本讨论之列,可以参考Smash

    css清除浮动clearfix:after的用法详解(附完整代码)

    CSS Code复制内容到剪贴板 .clearfix:before, .clearfix:after { content:; display:table; } .clearfix:after{ clear:both; overflow:hidden; } .clearfix{ *zoom:1; }  如果外部有一个div...

    中文网页重设与排版typo.css.zip

    (1) 专名号:使用标签 或者 .typo-u (2) 着重号:使用 class .typo-em (3) 首字下沉:使用 class .typo-first (4) 清理浮动:与一般 reset.css 保持一致 .clearfix 三、开源许可 Sofish Lin: founder, creator of ...

    css 的 float 与clear

    NULL 博文链接:https://ywzqzhangjiawei.iteye.com/blog/1490877

    css reset 重置样式介绍

    reset.css本意就是重置样式,我始终建议把.clearfix放入layout.css,而把h1、h2之类的定义放进typography.css

    CSS中使用clearfix清除浮动的方法

    主要介绍了CSS中使用clearfix清除浮动的方法,作者列出了几个clearfix的不同的使用方法进行对比,需要的朋友可以参考下

    css hack之清除浮动(clearfix)

    复制代码代码如下: ”clearfix”&gt; ”fl”&gt;&lt;/div&gt; ”fr”&gt;&lt;/div&gt; &lt;/div&gt; .clearfix:after{ visibility:hidden; display:block; font-size:0; content:” “; clear:both; height:0; } .clearfix { display: inline

    mastering-css:通过“ CSS大师”课程学习使用CSS进行布局

    掌握CSS学习CSS3,Web布局,自适应Web设计,SASS,LESS,Flexbox,CSS网格布局和Bootstrap 4。 持续时间:+ 20小时课程记录第1天:2020年11月22日,HTML5:简介创建一个简单的网页。 CSS的第一步选择器,字体,颜色...

    css 清除浏览器默认样式

    /* reset */ 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,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,...

    JS学习笔记相关代码-测试代码

    JS学习笔记相关文档 Login.html学习 placeholder 属性规定可描述输入字段预期值的简短的提示信息(比如:一个样本值或者预期格式的短描述)。 该提示会在用户输入值之前显示在输入字段中。 注意:placeholder 属性...

    用clearfix:after消除css浮动解决外部div不能撑开问题

    如果有一个DIV作为外部容器,内部的DIV如果设置了float样式,则外部的容器DIV因为内部没有clear,导致不能被撑开。使用clearfix:after,可以解决这个问题

Global site tag (gtag.js) - Google Analytics