CSS透明大汇总
浏览器兼容性问题大汇总

浏览器兼容性问题⼤汇总JavaScript1.HTML对象获取问题FireFox:document.getElementById(“idName”);ie:document.idname或者document.getElementById(“idName”).解决办法:统⼀使⽤document.getElementById(“idName”);2.const问题说明:Firefox下,可以使⽤const关键字或var关键字来定义常量;IE下,只能使⽤var关键字来定义常量.解决⽅法:统⼀使⽤var关键字来定义常量.3.event.x与event.y问题说明:IE下,event对象有x,y属性,但是没有pageX,pageY属性;Firefox下,event对象有pageX,pageY属性,但是没有x,y属性.解决⽅法:使⽤mX(mX = event.x ? event.x : event.pageX;)来代替IE下的event.x或者Firefox下的event.pageX.4.window.location.href问题说明:IE或者Firefox2.0.x下,可以使⽤window.location或window.location.href;Firefox1.5.x下,只能使⽤window.location.解决⽅法:使⽤window.location来代替window.location.href.5.frame问题以下⾯的frame为例:<frame src=”xxx.html” id=”frameId” name=”frameName” />(1)访问frame对象:IE:使⽤window.frameId或者window.frameName来访问这个frame对象.frameId和frameName可以同名。
Firefox:只能使⽤window.frameName来访问这个frame对象.另外,在IE和Firefox中都可以使⽤window.document.getElementById(“frameId”)来访问这个frame对象.(2)切换frame内容:在 IE和Firefox中都可以使⽤window.document.getElementById(“testFrame”).src = “xxx.html”或window.frameName.location = “xxx.html”来切换frame的内容.如果需要将frame中的参数传回⽗窗⼝(注意不是opener,⽽是parent frame),可以在frame中使⽤parent来访问⽗窗⼝。
css 背景色透明文字不透明

css 背景色透明文字不透明在FF/Chrome 等较新的浏览器中可以使用css属性background-color的rgba轻松实现背景透明,而文字保持不透明。
而IE6/7/8浏览器不支持rgba,只有使用IE的专属滤镜filter:Alpha 来实现,但是这样写法会把文字也变为透明,因此只有在透明容器的子节点(文本节点除外)内设置position:relative才能不继承其父元素的透明滤镜,代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Web开发者网络- </title><style type="text/css">.warp{ background:#eee url(back.jpg) no-repeat left top; width:440px; height:400px; border:1px solid #ccc;}.content { width:180px; height:260px; margin:0px auto; padding:30px 30px; background:rgba(255, 255, 255, 0.6)!important;filter:Alpha(opacity=60); background:#fff; /*使用IE专属滤镜实现IE背景透明*/ }.content p{ position:relative;} /*实现IE文字不透明*/</style></head><body><div class="warp"><div class="content"><p> 是WEB开发者学习交流必备网站。
CSS知识点总结

CSS知识点总结⼀.Css分类1.替代replaced elements:img input(radio button, checkbox, text)不可替代nonreplaces elements:html,xhtml,span,a,div,body,form,p,em,strong,2.block-level and inline-level:(block可以包含inline 元素,反过来是不可以的!) block-level:p div li ulinline-level: a span strong em b i u⼆.选择器2.元素选择器:P{}3. Grouping Selectors(分组)eg:h2, p {color: gray;}4.The universal selector(通配选择器)eg:* {color: red;}5. Grouping Declarationseg:h1 {font: 18px Helvetica; color: purple; background: aqua;}6.类选择器:.ddd7.ID选择器:#ddd8.属性选择器简单属性选择h1[class] {color: silver;}根据具体属性值p[class="warning"] {font-weight: bold;}根据部分属性值选择p[class~="warning"] {font-weight: bold;}⼦串匹配属性选择器[foo^="bar"][foo$="bar"][foo*="bar"]特定属性选择类型*[lang|="en"] {color: white;}9.使⽤⽂档结构后代选择器blockquote b, p b {color: gray;}选择⼦元素h1 > strong {color: red;}选择相邻兄弟元素h1 + p {margin-top: 0;}10.伪类选择器静态伪类:a:visited{}a:link{}(好像⽤不了)动态伪类:a:focus{}(常⽤于input元素)a:hover{}a:active{}选择第⼀个⼦元素:Li:first-child{}根据语⾔选择()*:lang(fr){}结合伪类:link:hover:active {color: orange;}伪元素选择器:设置⾸字母样式li:first-letter{ color:Red;设置第⼀⾏的样式:.aa:first-line{ color:Purple;}设置之前和之后元素的样式:a:before{ content:"{}"; color:Silver;}a:after{ content:"end"; color:Aqua;}三.结构和层叠1.特殊性:重要性:!Important (最强悍!) eg: p.dark {color: #333 !important; background: white;}内联样式特殊性:1000 ID选择器:0100 li#answer {color: navy;} /* 0,1,0,1 (winner) */类属性值,属性选择或伪类:0010 h2.grape{color: purple;}/* 0,0,1,1 (winner)*元素和伪元素:0001 h1 {color: red;} /* 0,0,0,1 */通配选择器:0000结合符:⽆继承:⽆(0特殊性⽐⽆特殊性的更强)Eg: * {color: gray;} ((当h1中有其他元素时win)h1#page-title {color: black;}2.继承a)Border:没有继承b)Body:可以向上继承到html,其他的都是向下继承3.层叠:具有相同特殊性的靠后的权重⼤按权重和来源排序:(p79)读者的重要声明>创作⼈员的重要声明>创作⼈员的正常声明>读者正常>⽤户代理声明按特殊性排序按顺序排序Lvha顺序⽐较重要:即live visited hover active四.值和单位1.数字2.百分数3.颜⾊命名颜⾊:blue green white red black maroon ...⽤GRB指定颜⾊函数式RGB颜⾊(百分数法:0%-100%,数字法:0-255)Eg:rgb(100%,100%,100%)rgb(0%,0%,0%)rgb(255,255,255)rgb(0,0,0)灰度表:p.one {color: rgb(0%,0%,0%);}p.two {color: rgb(20%,20%,20%);}p.three {color: rgb(40%,40%,40%);}p.four {color: rgb(60%,60%,60%);}p.five {color: rgb(80%,80%,80%);}p.six {color: rgb(0,0,0);}p.seven {color: rgb(51,51,51);}p.eight {color: rgb(102,102,102);}p.nine {color: rgb(153,153,153);}p.ten {color: rgb(204,204,204);}25%*255=63.75=64⼗六进制RGB颜⾊Web颜⾊:rgb值20%和52和33(⼗六进制)整除4.长度单位a)绝对长度单位:in,cm,mm,pt(点),pc(派卡)1in=2.54cm 1cm=0.3394in1 in=72pt 1 in=6pcB) 相对长度单位Em和ex:Px:1em=14px 1em=2exEm最好的度量单位5.URL绝对URL相对URL注意:url和开始括号之间不能有空格6.关键字None:不同于0,Inherit:它的属性值和⽗元素相同7.css2单位:p(110)a)⾓度值:deg, grad 和 radb)时间值:s,ms 1000ms=1sc)频率值:hz,mhz五.字体1.字体系列制定字体系列:p {font-family: TimesNR,serif;}p {font-family: Times,TimesNR,'New Century Schoolbook',Georgia,'New York',serif;} 有空格、包括“#”和”$”的时候加“单引号”Cursive必须加“双引号”2.字体加粗a)Font-weight:bold bolder mormal 100 --900 lighterb)相对⼤⼩关键字:Bolder 是相对于⽗级字体粗细⽽⾔3.字体⼤⼩a)Font-size:xx-small x-small small medium large x-large xx-large smaller larger inheritb)相对⼤⼩关键字:larger smallerc)绝对⼤⼩:xx-small x-small small medium large x-large xx-larged)百分数:根据⽗元素继承的⼤⼩来计算strong {font-weight: lighter; font-size:larger;}strong b {font-weight:lighter; font-size:200%;}4.风格和变形a)字体风格:Font-style:italic oblique normal inheritb)字体变形:font-variant:small-caps normal inherit(只对英⽂有⽤,对汉语没有影响)c)转换⼤⼩写:p{ text-transform:uppercase;}5.拉伸和调整字体a)字体拉伸:font-stretch:normal| wider | narrower | ultra-condensed | exTRa-condensed| condensed| semi-condensed| semi-expanded| expanded| exTRa-expanded| ultra-expanded | inheritb)我的浏览器不⽀持(可以忽略)6.Font属性a)等价:h1{ font-style:inherit; font-weight:bold; font-variant:small-caps; font-size:20px; font-family:Candara,Corbel;}h1{ font:inherit bold small-caps20px Candara,Corbel; }b)注意;前两个可以互换,后两个不可以,normal 可以省略c)增加⾏⾼:line-height,Eg:body {font-size: 12px;}h1 {font: bold italic200%/1.2Verdana,Helvetica,Arial,sans-serif;}7.字体匹配六.⽂本属性1.缩进和⽔平对齐a)缩进⽂本:(只能⽤于块级元素!)text-indent:3em 10%b)⽔平对齐:(只能⽤于块级元素!)text-align:left center right justify(两端对齐⽂本) inherit2.垂直对齐:元素中⽂本基线之间的最⼩距离a)Line-height:”line-height”减去“font-size”等于⾏间距i.Line-height:18px,0.33in,150%,1.5emii.适⽤于所有元素iii.⾏⾼和继承:Line-height值从⽗元素继承时,要从⽗元素计算,⽽不是⼦元素上计算。
CSS3透明色RGBA使用介绍

CSS3透明⾊RGBA使⽤介绍RGB对于⼤家来说⼀点不陌⽣,他就是红⾊R+绿⾊G+蓝⾊B,那现在我们所说的RGBA⼜是什么呢?说得简单⼀点就是在RGB的基础上加进了⼀个通道Alpha。
从⽽形成了我们今天需要讨论的RGBA。
如果需要更详细的解说,⼤家就跟着我⼀起往下看吧。
语法:R:红⾊值。
正整数 | 百分数G:绿⾊值。
正整数 | 百分数B:蓝⾊值。
正整数| 百分数A:透明度。
取值0~1之间取值:<length> :Hue(⾊调)。
0(或360)表⽰红⾊,120表⽰绿⾊,240表⽰蓝⾊,当然可取其他数值来确定其它颜⾊;<percentage> :Saturation(饱和度)。
取值为0%到100%之间的值;<percentage> :Lightness(亮度)。
取值为0%到100%之间的值;<opacity> :alpha(透明度)。
取值在0到1之间;说明:RGB⾊彩模式(也翻译为“红绿蓝”,⽐较少⽤)是⼯业界的⼀种颜⾊标准,是通过对红(R)、绿(G)、蓝(B)三个颜⾊通道的变化以及它们相互之间的叠加来得到各式各样的颜⾊的,RGB即是代表红、绿、蓝三个通道的颜⾊,这个标准⼏乎包括了⼈类视⼒所能感知的所有颜⾊,是⽬前运⽤最⼴的颜⾊系统之⼀。
RGBA在RGB的基础上多了控制alpha透明度的参数。
以上R、G、B三个参数,正整数值的取值范围为:0 - 255。
百分数值的取值范围为:0.0% - 100.0%。
超出范围的数值将被截⾄其最接近的取值极限。
并⾮所有浏览器都⽀持使⽤百分数值。
A参数,取值在0~1之间,不可为负值。
浏览器的兼容性:如果庞统说rgba是制作透明⾊(透明背景⾊、透明边框⾊、透明前景⾊等),⼤家不由会想起opacity 这个东西。
他在我们CSS2中制作背景⾊通常⽤到,可是要⽤他来制作边框⾊或都说前景⾊的话,那他就只能在边上站着了,有⼼⽆⼒呀。
如何用css代码让导航条透明化

如何用css代码让导航条透明化篇一:切入口CSS教程--第一讲.基于div+c制作精美的导航条效果什么是网页导航条?网页浏览时导航条起什么作用网站导航(navigation)是指通过一定的技术手段,为网站的访问者提供一定的途径,使其可以方便地访问到所需的内容一般在网站的logo、banner下面或是网页的顶部。
快速的使你了解网站的内容分类。
<ulcla="naver"><li><ahref="#">切入口</a></li><li><ahref="#">切入口</a></li><li><ahref="#">切入口</a></li><li><ahref="#">切入口</a></li><li><ahref="#">切入口</a></li><li><ahref="#">切入口</a></li><li><ahref="#">切入口</a></li></ul>.naver{width:100%;height:70p某;background:url('../image/lice.jpg')repeat-某;}.naverli{float:left;diplay:inline;/某主要用于解决ie6下的兼容问题某/line-height:70p某;width:102p某;background:url('../image/prite.jpg')no-repeat;te某t-indent:-900p某;overflow:hidden;}.naverli:hover{background:url('../image/prite.jpg')no-repeat0-70p某;}.naverli:active{background:url('../image/prite.jpg')no-repeat-102p某-70p某;}篇二:经典导航条div+c代码附图片经典导航条div+c代码附图片供初学者参考学习某{margin:0p某;padding:0p某;}body{font-family:Arial,Helvetica,an-erif;}div{width:98%;height:38p某;margin:30p某auto0p某auto;background:url(新建文件夹/bjnav.gif)repeat-某bottombottom; }ul{lit-tyle:none;}li{float:left;background:url(新建文件夹/bjli.gif);}lia{te某t-decoration:none;color:#000000;diplay:block;width:80p某;line-height:31p某;te某t-align:center;}lia:hover{background:url(新建文件夹/nav_hov.gif)no-repeat;color:#FFFFFF;te某t-decoration:underline;}.a1{background:url(新建文件夹/bgli_left.gif)no-repeat}.a2{background:url(新建文件夹/bgli_right.gif)no-repeat}.a3{background:url(新建文件夹/nav_hov.gif)}</tyle></head><body><div></div></body></html><ul></ul><licla="a1"><ahref="#">首页</a></li><li><ahref="#">财经</a></li><licla="a3"><ahref="#">体育</a></li><li><ahref="#">军事</a></li><li><ahref="#">漫画</a></li><li><ahref="#">新闻</a></li><li><ahref="#">娱乐</a></li><li><ahref="#">爱好</a></li><licla="a2"><ahref="#">链接</a></li>篇三:淘宝旺铺】导航CSS代码使用修改技巧淘宝旺铺】导航CSS代码使用修改技巧1.修改导航分类下面的背景色,代码如下:.kin-bo某-bd.link{background:#000000;}修改导航分类下面的图片,代码如下:.kin-bo某-bd.link{background:url(图片链接);}2.修改整个导航的背景色.kin-bo某-bd.menu-lit{background:#000000;}修改整个导航背景为图片.kin-bo某-bd.menu-lit{background:url(图片链接);}3.修改最右边留下的一小块,2里提到的,代码如下:.kin-bo某-bd{background:#000000;}修改成图片的代码如下:.kin-bo某-bd{background:url(图片链接);}4.字外加色:.kin-bo某-bd.menu-lit.menu-elected.link{background:#000000;} 5.字里加色:.kin-bo某-bd.menu-lit.menu-elected.link.title{background:#000000;}字外+字里=全部!----------------------------------------------------------------------------------------1.导航背景色代码(除去“所有分类”)如下:.menu-lit.link{background:#000000;}2.导航栏文字(除去“所有分类”)如下:.menu-lit.menu.title{color:#颜色代码;font-ize:字号p某;}3.“所有分类”的背景色代码如下:.all-cat.link{background:#000000;}4.“所有分类”的文字代码如下:.all-cat.link.title{color:#颜色代码;font-ize:字号p某;}最新代码,解决字体改大后导航右侧消失的情况!代码如下:.all-cat.link.title{font-ize:字号p某;}.all-cat.link{background:#3BAFFF;margin:0;padding:0p某3p某;}字号最大为21,继续变大右侧导航将消失!该代码还不是很完善,我们会继续研究!5.二级分类文字代码如下:.popup-content.cat-tree.ft-cat.cat-name{font-ize:字号p某;color:#颜色代码;font-weight:bold/bolder/normal;}6.二级分类背景代码如下:.popup-content{background:#000000;}7.三级分类文字代码(除去“所有宝贝”分类)如下.popup-content.cat-tree.nd-pop-inner{font-ize:字号p某;color:#颜色代码;font-weight:bold/bolder/normal;}8.三级分类文字代码(包括“所有宝贝”分类字体大小)这样就无法改变字体颜色,我们会继续完善该代码!如下.popup-content.cat-tree.nd-pop-inner{font-ize:字号p某;color:#颜色;}9.三级分类背景代码:.popup-content.cat-tree.nd-pop-inner{background:#000000;}10.一级导航分类(除去“所有宝贝”分类)分隔线颜色代码如下:.menu-lit.menu{border-color:#000000;}11.一级导航“所有宝贝”分类分隔线颜色代码如下:.all-cat.link{border-color:#000000;}12.一级导航分类的宽度修改代码如下:.menu-lit.menu{background:#颜色;margin:0;padding:0p某增加的宽度p某;}13.鼠标滑过一级分类导航文字变换背景色代码如下:.menu-lit.menu-hover.link{background:#000000;}14.鼠标滑过一级分类导航文字变换颜色代码如下:.menu-lit.menu-hover.link.title{color:#FFFFFF;}15.鼠标滑过二级分类导航文字变换背景色代码如下:.popup-content.cat-tree.cat-hd-hover{background:#000000;}16.鼠标滑过二级分类导航文字变换颜色代码如下:.kin-bo某-bd.popup-content.cat-tree.cat-hd-hover.cat-name{color:#ff0000;}17.鼠标滑过三级分类导航文字变换背景色代码如下:.popup-content.cat-tree.nd-cat-hd-hover{background:#000000;}18.二级分类上加空间代码如下:.popup-content.cat-tree{margin:0050p某0;}19.修改“所有宝贝”右边小图标代码如下:.all-cat.link.popup-icon{background:url(图片连接);}。
css样式大全,完整的Css样式大全(整理)

css样式⼤全,完整的Css样式⼤全(整理)CSS样式被称为为“层叠样式表”,是⼀种⽹页制作做不可或缺的技术,是⽤于装饰⽹页,达到设计效果的⼀种样式语⾔,下⾯将整理⼀下css 常⽤样式:字体属性:(font)⼤⼩ {font-size: x-large;}(特⼤) xx-small;(极⼩) ⼀般中⽂⽤不到,只要⽤数值就可以,单位:PX、PD样式 {font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常)⾏⾼ {line-height: normal;}(正常) 单位:PX、PD、EM粗细 {font-weight: bold;}(粗体) lighter;(细体) normal;(正常)变体 {font-variant: small-caps;}(⼩型⼤写字母) normal;(正常)⼤⼩写 {text-transform: capitalize;}(⾸字母⼤写) uppercase;(⼤写) lowercase;(⼩写) none;(⽆)修饰 {text-decoration: underline;}(下划线) overline;(上划线) line-through;(删除线) blink;(闪烁)常⽤字体: (font-family)"Courier New", Courier, monospace, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif, Verdana背景属性: (background)⾊彩 {}图⽚ {background-image: url();}重复 {background-repeat: no-repeat;}滚动 {background-attachment: fixed;}(固定) scroll;(滚动)位置 {background-position: left;}(⽔平) top(垂直);简写⽅法 {background:#000 url(..) repeat fixed left top;} /*简写·这个在阅读代码中经常出现,要认真的研究*/区块属性: (Block) /*这个属性第⼀次认识,要多多研究*/字间距 {letter-spacing: normal;} 数值 /*这个属性似乎有⽤,多实践下*/对齐 {text-align: justify;}(两端对齐) left;(左对齐) right;(右对齐) center;(居中)缩进 {text-indent: 数值px;}垂直对齐 {vertical-align: baseline;}(基线) sub;(下标) super;(下标) top; text-top; middle; bottom; text-bottom;词间距word-spacing: normal; 数值空格white-space: pre;(保留) nowrap;(不换⾏)显⽰ {display:block;}(块) inline;(内嵌) list-item;(列表项) run-in;(追加部分) compact;(紧凑) marker;(标记) table; inline-table; table-raw-group; table-header-group; table-footer-group; table-raw; table-column-group; table-column; table-cell; table-caption;(表格标题) /*display 属性的了解很模糊*/⽅框属性:(Box)width:; height:; float:; clear:both; margin:; padding:; 顺序:上右下左边框属性: (Border)border-style: dotted;(点线) dashed;(虚线) solid; double;(双线) groove;(槽线) ridge;(脊状) inset;(凹陷) outset;border-width:; 边框宽度border-color:#;简写⽅法border:width style color; /*简写*/列表属性: (List-style)类型list-style-type: disc;(圆点) circle;(圆圈) square;(⽅块) decimal;(数字) lower-roman;(⼩罗码数字) upper-roman; lower-alpha; upper-alpha;位置list-style-position: outside;(外) inside;图像list-style-image: url(..);定位属性: (Position)Position: absolute; relative; static;visibility: inherit; visible; hidden;overflow: visible; hidden; scroll; auto;clip: rect(12px,auto,12px,auto) (裁切)css属性代码⼤全⼀ CSS⽂字属性:color : #999999; /*⽂字颜⾊*/font-family : 宋体,sans-serif; /*⽂字字体*/font-size : 9pt; /*⽂字⼤⼩*/font-style:itelic; /*⽂字斜体*/font-variant:small-caps; /*⼩字体*/letter-spacing : 1pt; /*字间距离*/line-height : 200%; /*设置⾏⾼*/font-weight:bold; /*⽂字粗体*/vertical-align:sub; /*下标字*/vertical-align:super; /*上标字*/text-decoration:line-through; /*加删除线*/text-decoration: overline; /*加顶线*/text-decoration:underline; /*加下划线*/text-decoration:none; /*删除链接下划线*/text-transform : capitalize; /*⾸字⼤写*/text-transform : uppercase; /*英⽂⼤写*/text-transform : lowercase; /*英⽂⼩写*/text-align:right; /*⽂字右对齐*/text-align:left; /*⽂字左对齐*/text-align:center; /*⽂字居中对齐*/text-align:justify; /*⽂字分散对齐*/vertical-align属性vertical-align:top; /*垂直向上对齐*/vertical-align:bottom; /*垂直向下对齐*/vertical-align:middle; /*垂直居中对齐*/vertical-align:text-top; /*⽂字垂直向上对齐*/vertical-align:text-bottom; /*⽂字垂直向下对齐*/⼆、CSS边框空⽩padding-top:10px; /*上边框留空⽩*/padding-right:10px; /*右边框留空⽩*/padding-bottom:10px; /*下边框留空⽩*/padding-left:10px; /*左边框留空⽩三、CSS符号属性:list-style-type:none; /*不编号*/list-style-type:decimal; /*阿拉伯数字*/list-style-type:lower-roman; /*⼩写罗马数字*/list-style-type:upper-roman; /*⼤写罗马数字*/list-style-type:lower-alpha; /*⼩写英⽂字母*/list-style-type:upper-alpha; /*⼤写英⽂字母*/list-style-type:disc; /*实⼼圆形符号*/list-style-type:circle; /*空⼼圆形符号*/list-style-type:square; /*实⼼⽅形符号*/list-style-image:url(/dot.gif); /*图⽚式符号*/list-style-position: outside; /*凸排*/list-style-position:inside; /*缩进*/四、CSS背景样式:/*背景颜⾊*/background:transparent; /*透视背景*/background-image : url(/image/bg.gif); /*背景图⽚*/ background-attachment : fixed; /*浮⽔印固定背景*/ background-repeat : repeat; /*重复排列-⽹页默认*/ background-repeat : no-repeat; /*不重复排列*/ background-repeat : repeat-x; /*在x轴重复排列*/ background-repeat : repeat-y; /*在y轴重复排列*/指定背景位置background-position : 90% 90%; /*背景图⽚x与y轴的位置*/ background-position : top; /*向上对齐*/background-position : buttom; /*向下对齐*/ background-position : left; /*向左对齐*/ background-position : right; /*向右对齐*/ background-position : center; /*居中对齐*/五、CSS连接属性:a /*所有超链接*/a:link /*超链接⽂字格式*/a:visited /*浏览过的链接⽂字格式*/a:active /*按下链接的格式*/a:hover /*⿏标转到链接*/⿏标光标样式:链接⼿指 CURSOR: hand⼗字体 cursor:crosshair箭头朝下 cursor:s-resize⼗字箭头 cursor:move箭头朝右 cursor:move加⼀问号 cursor:help箭头朝左 cursor:w-resize箭头朝上 cursor:n-resize箭头朝右上 cursor:ne-resize箭头朝左上 cursor:nw-resize⽂字I型 cursor:text箭头斜右下 cursor:se-resize箭头斜左下 cursor:sw-resize漏⽃ cursor:wait光标图案(IE6) p {cursor:url("光标⽂件名.cur"),text;}六、CSS框线⼀览表:border-top : 1px solid #6699cc; /*上框线*/border-bottom : 1px solid #6699cc; /*下框线*/ border-left : 1px solid #6699cc; /*左框线*/border-right : 1px solid #6699cc; /*右框线*/以上是建议书写⽅式,但也可以使⽤常规的⽅式如下: border-top-color : #369 /*设置上框线top颜⾊*/ border-top-width :1px /*设置上框线top宽度*/ border-top-style : solid/*设置上框线top样式*/其他框线样式solid /*实线框*/dotted /*虚线框*/double /*双线框*/groove /*⽴体内凸框*/ridge /*⽴体浮雕框*/inset /*凹框*/outset /*凸框*/七、CSS表单运⽤:⽂字⽅块按钮复选框选择钮多⾏⽂字⽅块下拉式菜单选项1选项2⼋、CSS边界样式:margin-top:10px; /*上边界*/margin-right:10px; /*右边界值*/margin-bottom:10px; /*下边界值*/margin-left:10px; /*左边界值*/CSS 属性:字体样式(Font Style)序号中⽂说明标记语法1 字体样式 {font:font-style font-variant font-weight font-size font-family}2 字体类型 {font-family:"字体1","字体2","字体3",...}3 字体⼤⼩ {font-size:数值|inherit| medium| large| larger| x-large| xx-large| small| smaller| x-small| xx-small}4 字体风格 {font-style:inherit|italic|normal|oblique}5 字体粗细 {font-weight:100-900|bold|bolder|lighter|normal;}6 字体颜⾊ {color:数值;}7 阴影颜⾊ {text-shadow:16位⾊值}8 字体⾏⾼ {line-height:数值|inherit|normal;}9 字间距 {letter-spacing:数值|inherit|normal}10 单词间距 {word-spacing:数值|inherit|normal}11 字体变形 {font-variant:inherit|normal|small-cps }12 英⽂转换 {text-transform:inherit|none|capitalize|uppercase|lowercase}13 字体变形 {font-size-adjust:inherit|none}14 字体 {font-stretch:condensed|expanded|extra-condensed|extra-expanded|inherit|narrower|normal| semi-condensed|semi-expanded|ultra-condensed|ultra-expanded|wider}⽂本样式(Text Style)序号中⽂说明标记语法1 ⾏间距 {line-height:数值|inherit|normal;}2 ⽂本修饰 {text-decoration:inherit|none|underline|overline|line-through|blink}3 段⾸空格 {text-indent:数值|inherit}4 ⽔平对齐 {text-align:left|right|center|justify}5 垂直对齐 {vertical-align:inherit|top|bottom|text-top|text-bottom|baseline|middle|sub|super}6 书写⽅式 {writing-mode:lr-tb|tb-rl}背景样式序号中⽂说明标记语法1 背景颜⾊ { color: rgb(85, 85, 85); font-family: "Helvetica Neue", "Segoe UI", "Hiragino Sans GB", "Microsoft YaHei", Verdana, sans-serif; font-size: medium;">2 背景图⽚ {background-image: url(URL)|none}3 背景重复 {background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}4 背景固定 {background-attachment:fixed|scroll}5 背景定位 {background-position:数值|top|bottom|left|right|center}6 背影样式 {background:背景颜⾊|背景图象|背景重复|背景附件|背景位置}框架样式(Box Style)序号中⽂说明标记语法1 边界留⽩ {margin:margin-top margin-right margin-bottom margin-left}2 补 ⽩ {padding:padding-top padding-right padding-bottom padding-left}3 边框宽度 {border-width:border-top-width border-right-width border-bottom-width border-left-width} 宽度值: thin|medium|thick|数值4 边框颜⾊ {border-color:数值数值数值数值} 数值:分别代表top、right、bottom、left颜⾊值5 边框风格 {border-style:none|hidden|inherit|dashed|solid|double|inset|outset|ridge|groove}6 边 框 {border:border-width border-style color}上边框 {border-top:border-top-width border-style color}右边框 {border-right:border-right-width border-style color}下边框 {border-bottom:border-bottom-width border-style color}左边框 {border-left:border-left-width border-style color}7 宽 度 {width:长度|百分⽐| auto}8 ⾼ 度 {height:数值|auto}9 漂 浮 {float:left|right|none}10 清 除 {clear:none|left|right|both}分类列表序号中⽂说明标记语法1 控制显⽰ {display:none|block|inline|list-item}2 控制空⽩ {white-space:normal|pre|nowarp}3 符号列表 {list-style-type:disc|circle|square|decimal|lower-roman|upper-roman|lower-alpha|upper-alpha|none}4 图形列表 {list-style-image:URL}5 位置列表 {list-style-position:inside|outside}6 ⽬录列表 {list-style:⽬录样式类型|⽬录样式位置|url}7 ⿏标形状 {cursor:hand|crosshair|text|wait|move|help|e-resize|nw-resize|w-resize|s-resize|se-resize|sw-resize}。
20个CSSCSS3常用样式汇总

20个CSSCSS3常⽤样式汇总1.强制⽂本单⾏显⽰:white-space:nowrap;2.设置溢出⽂本显⽰为省略标记:text-overflow:ellipsis;(注:text-overflow:clip | ellipsis | ellipsis-word;(css3新增加的)其中clip表⽰直接裁切溢出的⽂本;值ellipsis表⽰⽂本溢出时,显⽰省略标记(...),省略标记代替最后⼀个字符;值ellipsis-word表⽰⽂本溢出时,也是显⽰省略标记(...),不同的是,省略标记代替的是最后⼀个词)3.例如⼀段代码:<a href="javascript:void(0)"><img src="images/suba.gif"></a>当点击a标签⾥⾯的图⽚的时候,有虚线框,IE中图⽚还有边框,如何解决?解决办法:a{outline:none;}//主要是针对⽕狐等浏览器,但IE不⾏img{border:0;}a:active{noOutline:expression(this.onFocus=this.blur());}//解决IE6,IE7中的虚线框。
对于a标签来说,⼀般简单的解决办法是:在a标签⾥加⼊js控制,当a标签被聚焦时,强制取消焦点,这时候a标签⾃然不会有虚线框。
<a href="#" onfocus="this.blur();">测试</a>但是当连接太多的时候,⼀个⼀个的加这段代码不实⽤4.html中两张图横向回车导致间隙,怎么才能去除成为⽆间隙?例如:div 宽300px ; img 宽100px; border:0px;复制代码代码如下:<div><img /><img /><img /></div>//上⾯情况刚好显⽰三张图</p> <p><div><img /><img /><img /></div>这种情况就⽆法在横向显⽰三张图,因为回车导致两图间有间隙。
css样式大全(整理版)

字体属性:(font)大小{font-size: x-large;}(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX、PD样式{font-style: oblique;}(偏斜体) italic;(斜体) normal;(正常)行高{line-height: normal;}(正常) 单位:PX、PD、EM粗细{font-weight: bold;}(粗体) lighter;(细体) normal;(正常)变体{font-variant: small-caps;}(小型大写字母) normal;(正常)大小写{text-transform: capitalize;}(首字母大写) uppercase;(大写) lowercase;(小写) none;(无)修饰{text-decoration: underline;}(下划线) overline;(上划线) line-through;(删除线) blink;(闪烁)常用字体:(font-family)"Courier New", Courier, monospace, "Times New Roman", Times, serif, Arial, Helvetica, sans-serif, Verdana背景属性:(background)色彩{background-color: #FFFFFF;}图片{background-image: url();}重复{background-repeat: no-repeat;}滚动{background-attachment: fixed;}(固定) scroll;(滚动)位置{background-position: left;}(水平) top(垂直);简写方法{background:#000 url(..) repeat fixed left top;} /*简写·这个在阅读代码中经常出现,要认真的研究*/区块属性:(Block) /*这个属性第一次认识,要多多研究*/字间距{letter-spacing: normal;} 数值/*这个属性似乎有用,多实践下*/对齐{text-align: justify;}(两端对齐) left;(左对齐) right;(右对齐) center;(居中)缩进{text-indent: 数值px;}垂直对齐{vertical-align: baseline;}(基线) sub;(下标) super;(下标) top; text-top; middle; bottom; text-bottom;词间距word-spacing: normal; 数值空格white-space: pre;(保留) nowrap;(不换行)显示{display:block;}(块) inline;(内嵌) list-item;(列表项) run-in;(追加部分) compact;(紧凑) marker;(标记) table; inline-table; table-raw-group;table-header-group; table-footer-group; table-raw; table-column-group; table-column; table-cell; table-caption;(表格标题) /*display 属性的了解很模糊*/方框属性:(Box)width:; height:; float:; clear:both; margin:; padding:; 顺序:上右下左边框属性:(Border)border-style: dotted;(点线) dashed;(虚线) solid; double;(双线) groove;(槽线) ridge;(脊状) inset;(凹陷) outset;border-width:; 边框宽度border-color:#;简写方法border:width style color; /*简写*/列表属性:(List-style)类型list-style-type: disc;(圆点) circle;(圆圈) square;(方块) decimal;(数字) lower-roman;(小罗码数字) upper-roman; lower-alpha; upper-alpha;位置list-style-position: outside;(外) inside;图像list-style-image: url(..);定位属性:(Position)Position: absolute; relative; static;visibility: inherit; visible; hidden;overflow: visible; hidden; scroll; auto;clip: rect(12px,auto,12px,auto) (裁切)css属性代码大全一CSS文字属性:color : #999999; /*文字颜色*/font-family : 宋体,sans-serif; /*文字字体*/font-size : 9pt; /*文字大小*/font-style:itelic; /*文字斜体*/font-variant:small-caps; /*小字体*/letter-spacing : 1pt; /*字间距离*/line-height : 200%; /*设置行高*/font-weight:bold; /*文字粗体*/vertical-align:sub; /*下标字*/vertical-align:super; /*上标字*/text-decoration:line-through; /*加删除线*/text-decoration: overline; /*加顶线*/text-decoration:underline; /*加下划线*/text-decoration:none; /*删除链接下划线*/text-transform : capitalize; /*首字大写*/text-transform : uppercase; /*英文大写*/text-transform : lowercase; /*英文小写*/text-align:right; /*文字右对齐*/text-align:left; /*文字左对齐*/text-align:center; /*文字居中对齐*/text-align:justify; /*文字分散对齐*/vertical-align属性vertical-align:top; /*垂直向上对齐*/vertical-align:bottom; /*垂直向下对齐*/vertical-align:middle; /*垂直居中对齐*/vertical-align:text-top; /*文字垂直向上对齐*/ vertical-align:text-bottom; /*文字垂直向下对齐*/ 二、CSS边框空白padding-top:10px; /*上边框留空白*/padding-right:10px; /*右边框留空白*/padding-bottom:10px; /*下边框留空白*/ padding-left:10px; /*左边框留空白三、CSS符号属性:list-style-type:none; /*不编号*/list-style-type:decimal; /*阿拉伯数字*/list-style-type:lower-roman; /*小写罗马数字*/ list-style-type:upper-roman; /*大写罗马数字*/ list-style-type:lower-alpha; /*小写英文字母*/list-style-type:upper-alpha; /*大写英文字母*/list-style-type:disc; /*实心圆形符号*/list-style-type:circle; /*空心圆形符号*/list-style-type:square; /*实心方形符号*/list-style-image:url(/dot.gif); /*图片式符号*/list-style-position: outside; /*凸排*/list-style-position:inside; /*缩进*/四、CSS背景样式:background-color:#F5E2EC; /*背景颜色*/background:transparent; /*透视背景*/background-image : url(/image/bg.gif); /*背景图片*/ background-attachment : fixed; /*浮水印固定背景*/ background-repeat : repeat; /*重复排列-网页默认*/ background-repeat : no-repeat; /*不重复排列*/ background-repeat : repeat-x; /*在x轴重复排列*/ background-repeat : repeat-y; /*在y轴重复排列*/指定背景位置background-position : 90% 90%; /*背景图片x与y轴的位置*/ background-position : top; /*向上对齐*/background-position : buttom; /*向下对齐*/background-position : left; /*向左对齐*/background-position : right; /*向右对齐*/background-position : center; /*居中对齐*/五、CSS连接属性:a /*所有超链接*/a:link /*超链接文字格式*/a:visited /*浏览过的链接文字格式*/a:active /*按下链接的格式*/a:hover /*鼠标转到链接*/鼠标光标样式:链接手指CURSOR: hand十字体cursor:crosshair箭头朝下cursor:s-resize十字箭头cursor:move箭头朝右cursor:move加一问号cursor:help箭头朝左cursor:w-resize箭头朝上cursor:n-resize箭头朝右上cursor:ne-resize箭头朝左上cursor:nw-resize文字I型cursor:text箭头斜右下cursor:se-resize箭头斜左下cursor:sw-resize漏斗cursor:wait光标图案(IE6) p {cursor:url("光标文件名.cur"),text;} 六、CSS框线一览表:border-top : 1px solid #6699cc; /*上框线*/ border-bottom : 1px solid #6699cc; /*下框线*/ border-left : 1px solid #6699cc; /*左框线*/ border-right : 1px solid #6699cc; /*右框线*/以上是建议书写方式,但也可以使用常规的方式如下: border-top-color : #369 /*设置上框线top颜色*/ border-top-width :1px /*设置上框线top宽度*/ border-top-style : solid/*设置上框线top样式*/其他框线样式solid /*实线框*/dotted /*虚线框*/double /*双线框*/groove /*立体内凸框*/ridge /*立体浮雕框*/inset /*凹框*/outset /*凸框*/七、CSS表单运用:文字方块按钮复选框选择钮多行文字方块下拉式菜单选项1选项2八、CSS边界样式:margin-top:10px; /*上边界*/margin-right:10px; /*右边界值*/margin-bottom:10px; /*下边界值*/margin-left:10px; /*左边界值*/CSS 属性:字体样式(Font Style)序号中文说明标记语法1 字体样式{font:font-style font-variant font-weight font-size font-family}2 字体类型{font-family:"字体1","字体2","字体3",...}3 字体大小{font-size:数值|inherit| medium| large| larger| x-large| xx-large| small| smaller| x-small| xx-small}4 字体风格{font-style:inherit|italic|normal|oblique}5 字体粗细{font-weight:100-900|bold|bolder|lighter|normal;}6 字体颜色{color:数值;}7 阴影颜色{text-shadow:16位色值}8 字体行高{line-height:数值|inherit|normal;}9 字间距{letter-spacing:数值|inherit|normal}10 单词间距{word-spacing:数值|inherit|normal}11 字体变形{font-variant:inherit|normal|small-cps }12 英文转换{text-transform:inherit|none|capitalize|uppercase|lowercase}13 字体变形{font-size-adjust:inherit|none}{font-stretch:condensed|expanded|extra-condensed|extra-expanded|inherit| narrower|normal|semi-condensed|semi-expanded|ultra-condensed|ultra-expanded|wider}文本样式(Text Style)序号中文说明标记语法1 行间距{line-height:数值|inherit|normal;}2 文本修饰{text-decoration:inherit|none|underline|overline|line-through|blink}3 段首空格{text-indent:数值|inherit}4 水平对齐{text-align:left|right|center|justify}5 垂直对齐{vertical-align:inherit|top|bottom|text-top|text-bottom|baseline|middle|sub| super}6 书写方式{writing-mode:lr-tb|tb-rl}背景样式序号中文说明标记语法1 背景颜色{background-color:数值}2 背景图片{background-image: url(URL)|none}3 背景重复{background-repeat:inherit|no-repeat|repeat|repeat-x|repeat-y}4 背景固定{background-attachment:fixed|scroll}5 背景定位{background-position:数值|top|bottom|left|right|center}6 背影样式{background:背景颜色|背景图象|背景重复|背景附件|背景位置}框架样式(Box Style)序号中文说明标记语法1 边界留白{margin:margin-top margin-right margin-bottom margin-left}2 补白{padding:padding-top padding-right padding-bottom padding-left}3 边框宽度{border-width:border-top-width border-right-widthborder-bottom-width border-left-width}宽度值:thin|medium|thick|数值4 边框颜色{border-color:数值数值数值数值}数值:分别代表top、right、bottom、left颜色值{border-style:none|hidden|inherit|dashed|solid|double|inset|outset|ridge|gro ove}6 边框{border:border-width border-style color}上边框{border-top:border-top-width border-style color}右边框{border-right:border-right-width border-style color}下边框{border-bottom:border-bottom-width border-style color}左边框{border-left:border-left-width border-style color}7 宽度{width:长度|百分比| auto}8 高度{height:数值|auto}9 漂浮{float:left|right|none}10 清除{clear:none|left|right|both}分类列表序号中文说明标记语法1 控制显示{display:none|block|inline|list-item}2 控制空白{white-space:normal|pre|nowarp}3 符号列表{list-style-type:disc|circle|square|decimal|lower-roman|upper-roman|lower-a lpha|upper-alpha|none}4 图形列表{list-style-image:URL}5 位置列表{list-style-position:inside|outside}6 目录列表{list-style:目录样式类型|目录样式位置|url}7 鼠标形状{cursor:hand|crosshair|text|wait|move|help|e-resize|nw-resize|w-resize|s-re size|se-resize|sw-resize}。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
近年来,CSS不透明算得上是一种相当流行的技术,但在跨浏览器支持上,对于开发者来说,可以说是一件令人头疼的事情。
目前还没有一个通用方法,以确保透明度设置可以在目前使用的所有浏览器上有效。
这篇汇总主要是提供一些CSS不透明的详细介绍,代码示例和解释,以实现这项有用的CSS 技术在您的项目中兼容所有浏览器。
关于CSS 透明度,有一点需要注意的是,它虽然使用了很多年,但它一直以来都不是一个标准属性。
它是一种非标准技术,应该是CSS3规范的一部分。
1. 旧的Opacity设置
以下代码是Firefox和Safari旧版本所需的透明度设置:
#myElement {-khtml-opacity: .5; -moz-opacity: 0.5;}
-khtml-opacity设置是针对旧版本的Webkit渲染引擎,这种专用属性现在已经过时了,除非你还有需要兼容Safari 1.x.的用户。
第二行使用专用属性-moz-opacity是为了兼容Mozilla渲染引擎的早期版本,以及追溯到Netscape Navigator。
Firefox 0.9以后就不要求使用-moz-opacity属性,Firefox 3.5(现在使用Gecko引擎)已经不在支持这个属性。
2. 在Firefox, Safari, Chrome和Opera下的CSS透明度
以下代码是除了IE外的所有当前浏览器的最简单,最最新的不透明度设置的CSS语法:
#myElement {opacity: .7;}
上述语法将设置一个元素为70%不透明(或30%透明)。
设置opacity:1将使元素不透明,而设置opacity:0将使得元素完全不可见。
你只要记住“opacity”等同于“不透明”就很容易记住了,opacity值越小就越接近透明。
opacity属性可以精确地小数点后两位,所以值取“.01”和“.02”实际上是不同的,虽然可见度很难被发觉。
一般情况下,精确到一位就可以了,取值如“.3”或“.7”。
3. IE下的CSS透明度
IE下照旧有别于其他浏览器,并且目前也有三个不同版本的IE在广泛使用,透明度设置是不同的,有时需要额外的CSS来控制:
#myElement {filter: alpha(opacity=40);}
上面的CSS使用专用的filter属性来设置IE6-8透明度。
对于IE6和IE7需要注意:为了使得透明设置生效,元素必须是“有布局”。
一个元素可以通过使用一些CSS属性来使其被布局,有如width 和position。
关于微软专有的hasLayout属性详情,以及如何触发它,参考这里。
另外一个设置IE8的CSS透明度的方法语法如下(注意注释中指出的版本):
#myElement{filter: progid:DXImageTransform.Microsoft.Alpha(opacity=40);/* 第一行在IE6, IE7和IE8下有效*/
-ms-filter: "progid:DXImageT ransform.Microsoft.Alpha(opacity=40)"; /*第二行仅在IE8下有效*/}
第一行代码针对当前所有IE版本,第二行仅针对IE8。
注意两行代码的不同之处:在第二行代码中,在filter属性前跟着-ms-前缀,并且属性值有加引号,这些都是语法所必须的。
说实在,有了如前一个例子中用alpha(opacity=40)的语法来作用于任何版本的IE下的任何有布局的元素之后,我也不确定是否还有必要用“progid”的方法。
4. 使用JavaScript设置和改变CSS透明度
您可以使用下面的语法访问JavaScript中的CSS opacity 属性:
document.getElementById("myElement").style.opacity = ".4"; // 针对所有现代浏览器document.getElementById("myElement").style.filter = "alpha(opacity=40)";// 针对IE
上面的代码可以使用行内循环或者其他动态函数递增修改透明度的值。
当然,你必须先通过特征检测来决定使用哪一行代码。
5. 使用JQuery设置和改变CSS透明度
直接使用jQuery设置CSS透明度更直观更容易实现,因为在所有浏览器代码都一样,并且你不必担心在IE下元素是否“haslayout”:
$("#myElement").css({opacity:.4 }); // 所有浏览器有效
您也可以使用一下jQuery代码使一个元素动画透明:
$("#myElement").animate({opacity:.4}, 1000, function() { // 动画完成,所有浏览器下有效});
不管元素的透明度在动画开始时是多少,它都会渐变到透明度为“.4”。
动画的速度通过值“1000”设定,动画时间以毫秒为单位。
代码中的最后一个属性是一个可选回调函数,将在动画完成后执行。
如果该元素的透明度在CSS中已经设定为“.4”,那在动画运行的时候,你将不会发觉有任何不同,所以动画开始和最终透明度要有所不同。
6. 通过RGBA的透明度
另一个CSS3技术只支持部分新的浏览器(Firefox 3+, Opera 10.1+, Chrome 2+,Safari 3.1+),可通过RGBA的alpha通道的方式设定。
语法如下:
#rgba { background: rgba(98, 135, 167, .4);}
在上面的定义中,通过RGB(前三个数字)给背景设定颜色,然后最后一个是alpha设置,以执行给定颜色的透明度。
这个alpha设置跟opacity 属性一样,可设定任何0到1的数字,精确得到两位小数点。
数字值越大,就越接近完全不透明的颜色。
7. 通过HSLA的透明度
类似之前的定义,CSS3还允许使用HSLA单独设置颜色和alpha值,HSLA表示Hue(色调), Saturation(饱和度), Lightness(亮度), 和Alpha。
以下是HSLA透明的例子:
#hsla {background: hsla(207, 38%, 47%, .4);}
更多关于HSLA颜色的解释,参考这篇来自的文章。
如同RGBA透明度,最后的数字表示透明度设置,跟RGBA起同样的作用。
注意RGBA和HSLA透明度的一个重要的好处是这些透明度设置不会影响到子元素的,但通过opacity属性的方式则会。
alpha设置的RGBA 和HSLA只影响背景颜色的透明度,仅此而已。
我希望我能涉及主要的跨浏览器的CSS透明度代码。
如果内容有错漏,欢迎随时评论指出,我将乐意作更正或补充。
谢谢~。