CSS 使用总结教学文案

上传人:go****e 文档编号:137373839 上传时间:2020-07-07 格式:DOC 页数:10 大小:39KB
返回 下载 相关 举报
CSS 使用总结教学文案_第1页
第1页 / 共10页
CSS 使用总结教学文案_第2页
第2页 / 共10页
CSS 使用总结教学文案_第3页
第3页 / 共10页
CSS 使用总结教学文案_第4页
第4页 / 共10页
CSS 使用总结教学文案_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《CSS 使用总结教学文案》由会员分享,可在线阅读,更多相关《CSS 使用总结教学文案(10页珍藏版)》请在金锄头文库上搜索。

1、CSS 使用总结精品文档CSS使用总结一、 CSS常用1. 去火狐IE链接点击虚线a text-decoration:none;outline: none; /* firefox */hide-focus: expression(this.hideFocus = true); /* ie */2. 英文或数字自动换行1)英文或汉字自动换行style=word-wrap:break-word ;width:630px;2)汉字一行显示,不换行word-break:keep-all;/* 不换行 */white-space:nowrap;/* 不换行 */3. 兼容两浏览器的AP值FILTER:

2、alpha(opacity=75);opacity: 0.754. 层中图片自动缩放imgmax-width:500px;width:expression(this.width500?500px:this.width+px); 5.content-width MARGIN: auto;WIDTH: 600px;.content-width imgMAX-WIDTH: 100%!important;HEIGHT: auto!important;width:expression(this.width 600 ? 600px : this.width)!important;6DIV中图片垂直居中.b

3、ixborder:1px solid #f00;width:300px;height:300px;text-align:center;vertical-align:middle;display:table-cell;*font-size:270px;*font-family:Arial;.bix imgvertical-align:middle;二、 CSS各浏览器区分规则1. 单独区分规则可被FireFox和IE7识别:!important例:margin:0px!important;可被IE6、IE7识别:* 例:*margin:0px;可被IE6识别:_ 例:_margin:0px;可被

4、IE7识别:*+ 例:*+margin:0px;可被IE8识别:9 例:margin:0px9;可被Safari识别:例:.boxmargin:0px;media screen and (-webkit-min-device-pixel-ratio:0) .boxmargin:10px;/* Safari rules here */可被 火狐 识别:-moz-document url-prefix() .boxmargin:10px; 2. 混写实例1) 区别IE6 与FF background: yellow ;*background: blue ; 【FF:黄色 IE6:蓝色】2) 区别I

5、E6与IE7 background: yellow!important;background: blue ; 【IE7:黄色 IE6:蓝色】3) 区别IE7 与FF background: yellow ; *background: blue;【FF:黄色 IE7:蓝色】4) 区别FF ,IE7 ,IE6 background: yellow ; * background: green !important ; * background: blue ; 【FF:黄色 IE7:绿色IE6:蓝色】5)还可以这样来区别FF ,IE7 ,IE6 background:yellow ;*backgrou

6、nd: green ;_background: blue ;【FF:黄色 IE7:绿色 IE6:蓝色】6)区别FF ,IE8 ,IE7 ,IE6 ,Safaribackground: yellow ;background: red 9; *background: green ;_background: blue ;media screen and (-webkit-min-device-pixel-ratio:0) . background: black ;/* Safari rules here */【FF:黄色 IE8:红色 IE7:绿色 IE6:蓝色 Safari:黑色】.clearfi

7、xzoom:1; .clearfix:aftercontent:.;display:block;visibility:hidden;clear:both;height:0px; 注:仅IE支持在属性值后加上“9” IE6 IE7能识别“*” FF和IE8不能识别“*”IE7能识别“*”也能识别“!important”IE6能识别“_”不能识别“!important”FF 能识别“!important”不能识别“*” “_”IE8 能识别“!important”也能识别“9”不管是什么方法,书写的顺序都是: FF IE8 IE7IE6三、 JS网页常用1. IFRAME使用问题1) iframe

8、中新窗口打开:onclick=window.open(ebhg_ms.html);2) iframe中打开上级链接:onclick=parent.show(cover5,alertmsg5); 四、 JS网页常用1) 打印代码:/打印代码function doPrint() var bdhtml=window.document.body.innerHTML; var sprnstr=;/开始标记 var eprnstr=;/结束标记 /保存打印时不需要的数据 var beforePrnHtml = bdhtml.substr(0,bdhtml.indexOf(sprnstr)+17); var

9、 afterPrnHtml = bdhtml.substr(bdhtml.indexOf(eprnstr); /提取欲打印的数据 var prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); var prnhtmlprnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr); window.document.body.innerHTML=prnhtml; /打印 window.print(); /恢复页面,可再次打印 window.document.body.innerHTML=bdhtml; 与(内容

10、段)(A链接代码)五、Css优化代码写法font(字体属性-字体的属性如下:font-style:italic; 字体样式font-variant:small-caps; 字体异体font-weight:bold; 字体加粗font-size:12px; 字大小为12pxline-height:22px;字行高为22px font-family:黑体 字体为黑体字font:italic small-caps bold 12px/22px 黑体;这里主要介绍是CSS代码的共用属性提取来达到节约代码、维护方便,如下:.yangshi_a width:100px; height:20px; text

11、-align:left; float:left; font-size:24px;.yangshi_b width:100px; height:20px; text-align:right; float:left; font-size:24px;他们都有相同高度、宽度、浮动、文字大小,而只有内容居左居右不同(你可能需要了解CSS居中),我们就可以提取他们相同属性优化后:.yangshi_a ,.yangshi_b width:100px; height:20px; text-align:left; float:left; font-size:24px;.yangshi_btext-align:r

12、ight; 注意观察以上代码,自己理解,不懂可到CSS论坛提出问题。*margin-top:0 !important;inputtype=text width:150px; display:block; margin-bottom:10px; background-color:yellow; font-family: Verdana, Arial;inputtype=button width:120px; margin-left:35px; display:block; font-family: Verdana, Arial;六、容易产生兼容问题元素分析div+css做的网页,有时候在IE下看

13、没生那么问题,但在ff测试却不堪入目,主要原因是代码的不规范书写,分析原因如下:1、 居中问题div里的内容,ie默认为居中,而ff默认为左对齐。使ff内容居中的方法是增加代码margin:auto;2、高度问题设有两横行div排列,上面的div设置高度(height),如果div里的实际内容大于所设高度,在ff中会出现两个div重叠的现象;但 在ie中, 下面的div会自动给上面的div让出空间。所以为避免出现层的重叠,高度一定要控制恰当,或者干脆不写高度,让他自动调节。或者设置:overflow:hidden3、clear:both;拿footer为例,有时候如果上面使用 了float控制

14、的n列的布局,那么在用ff浏览时footer很有可能不老实,到处乱动因为他还在受到浮动(float)的控制。如果想让它老老实 实呆在页面下方,在footer的div中写入clear:both;就可以达到效果了!4、浮动ie产生的双倍距离#boxfloat:left;width:100px;margin:0 0 0 100px; /这种情况之下IE会产生200px的距离display:inline; /使浮动忽略.clearfixzoom:1; .clearfix:aftercontent:.;display:block;visibility:hidden;clear:both;height:0px; 将浮动清除5、重点讲

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 幼儿/小学教育 > 其它小学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号