1,Cascading Style Sheets 层叠样式表
2,Content Scrambling System DVD电影的加密系统
3,Cast Semi-Steel 半铸钢, 钢性铸铁
4,College Scholarship Service 大学奖学金处
其中在网络上最常见的是Cascading Style Sheets(层叠样式表)
什么是Cascading Style Sheets(层叠样式表)
* CSS是Cascading Style Sheets(层叠样式表)的简称.
* CSS语言是一种标记语言,它不需要编译,可以直接由浏览器执行(属于浏览器解释型语言).
* 在标准网页设计中CSS负责网页内容(XHTML)的表现.
* CSS文件也可以说是一个文本文件,它包含了一些CSS标记,CSS文件必须使用css为文件名后缀.
* 可以通过简单的更改CSS文件,改变网页的整体表现形式,可以减少我们的工作量,所以她是每一个网页设计人员的必修课.
* CSS是由W3C的CSS工作组产生和维护的.
Cascading Style Sheets(层叠样式表)的历史
* 1996年W3C正式推出了CSS1.
* 1998年W3C正式推出了CSS2.
* CSS2.1是W3C现在正在推荐使用的.
* CSS3现在还处于开发中.
网页设计中常用的CSS属性
文字或元素的颜色 color
背景颜色 background-color
背景图像 background-image
字体 font-family
文字大小 font-size
列表样式 list
鼠标样式 cursor
边框样式 border
内补白 padding
外边距 margin
等...
css可以用任何写文本的工具进行开发,如文本工具,dreamweaver开发
css也是一种语言,这种语言要和html或者xhtml语言相结合才起作用,
css简单来说就是用来美化网页用的,用css语言来控制网页的外观
举个例子
xhtml部分:
<ul>
<li><a href="#">主页</a></li>
<li><a href="#">留言</a></li>
<li><a href="#">论坛</a></li>
</ul>
此时在页面上的表达形式是一个竖向列表,这样不够美观,
可以css来改善这个列表为一个横向导航条和超链接
css部分:
ul{list-style:nonemargin:0pxpadding:0px}
ul li{margin:0pxpadding:0pxfloat:left}
ul li a{display:blockwidth:100pxheight:30pxbackground:#efefefcolor:#333text-decoration:none}
ul li a:hover{background:#333color:#fff}
添加上css后,这个列表变成横向的导航条了,超级链接是淡色背景,灰色字体,没有下划线,高度是30像素,宽度是100像素
当我们鼠标经过这个超级链接时候,变成灰色背景,白色字体
这个可以换种方式实现,首先select的样式每个浏览器都有其默认的样式,需要先去除这些默认样式,其次,select里面的样式诸如箭头,下拉框等等的样式,这里提供一种思路,就是在select的外层添加一个div,对这个div元素设置样式,select元素则是没样式,从而达到一种掩眼法的效果,实现方式如下:
<!-- html 布局 --><div id="selectStyle">
<select id="select">
<option>option 1</option>
<option>option 2</option>
<option>option 3</option>
<option>option 4</option>
<option>option 5</option>
</select>
</div>
首先要去掉 #select 的默认样式:
/* 去掉默认样式,设置新的样式 */#select{
display:block
width:100%
height:100%
box-sizing:border-box
background:none
border:1px solid #222
outline:none
-webkit-appearance:none
padding:0 5px
line-height:inherit
color:inherit
cursor:default
font-size:14px
position:relative
z-index:3
}
#select option{
color:#222
}
#select option:hover{
color:#fff
}
#select option:checked{
background:#535353
color:#fff
}
然后在外层div#selectStyle设置自定义样式
#selectStyle{display:block
margin:0 auto
overflow:hidden
height:30px
width:240px
border-radius:0
background:#535353 url("箭头图片地址") right center no-repeat
background-size:auto 80%
color:#fff
line-height:2
/* 如果不想加图片,
则可以设置一个自己的三角形样式,
如下的自定义方式,
见代码1 */
position:relative
z-index:1
}
/* 代码1 */
#selectStyle:before{
position:absolute
z-index:1
top:50%
right:10px
margin-top:-2.5px
display:block
width:0
height:0
border-style:solid
border-width:5px 5px 0 5px
border-color:#fff transparent transparent transparent
content:""
}
/* 代码1 */
#selectStyle:after{
position:absolute
z-index:1
top:50%
right:10px
margin-top:-3.5px
display:block
width:0
height:0
border-style:solid
border-width:5px 5px 0 5px
border-color:#535353 transparent transparent transparent
content:""
}
以上就是自定义select样式的方法;
同时也可以完全不要select这个元素使用div+css来自定义一个跟select一样效果的下拉框(需要Javascript辅助)。