CSS常用属性及对应简单介绍解释
完整更多CSS属性样式教程栏目://www.yfnd.net/css/
宽度:width 使用实例:.yangshi{ width:100px;},即可设置对象宽度为100px
高度:height 使用实例:.yangshi{ height:100px;} 即可设置对象高度为100px
边框:border,请大家先看此属性详细教程//www.yfnd.net/css/912.shtml
内补白:padding 请大家先看此属性教程//www.yfnd.net/css/984.shtml
外补白:margin 请大家先看此属性教程//www.yfnd.net/css/1006.shtml
文字字体:font-family 使用实例:.yangshi{ font-family:"黑体";} 即设置对象字体为黑体
上下居中高度:line-height 使用实例:.yangshi{ line-height:22px;} 即设置对象文字内容上下距离为22px
文字大小:font-size 使用实例:.yangshi{ font-size:12px;} 即设置文字内容文字大小尺寸为12px
文字颜色:color 使用实例:.yangshi{ color:#F00} 即设置文字颜色为红色(颜色可以借助DW软件选择)
带超链接文字颜色:.yangshi a{ color:#F00} 设置该yangshi对象里带链接文字颜色为红色
鼠标经过带链接文字颜色:.yangshi a:hover{ color:#F00} 设置yangshi对象里带链接文字鼠标经过时变红色
CSS超链接 详介绍//www.yfnd.net/css/57.shtml
下划线:text-decoration 使用实例 .yangshi a{ text-decoration:underline} 设置yangshi对象里带链接文字加下划线
文字加粗:font-weight 使用实例 .yangshi{ font-weight:bold;}
浮动(居左、居右):float 使用实例.yangshi{ float:left;}设置对象向左浮动(局左)
.yangshi2{ float:right;} 设置对象向右浮动(局右)
在浮动中没有居中的设置,那就需要对上一级设置内容居中,然后再设置对象 margin:0 auto即可。
左右居中://www.yfnd.net/css/8.shtml
上下居中://www.yfnd.net/css/108.shtml
背景:background 详情://www.yfnd.net/css/1119.shtml 常用:background:url(bgimg.gif) no-repeat 5px 5px; 说明:背景图片为bgimg.gif ,不重复,距右距离右边5px 距上距离5px
这里要注意的
no-repeat 5px 5px 这2个5px
两个位置是不同的属性
第一个5px是距离左离多远 而第2个5px是距离上离多远
对html图片控制img: .yangshi img{ width:100px; border:1px solid #000;} 即 yangshi对象里的图片 宽度固定为100px, 黑色边框为1px属性
绝对定位(position):绝对定位 组合 设置某处布局的绝对定位,首先需要设置其父级的CSS属性里加position:relative,然后该对象子级再设置position:absolute,再设置该对象left和top 局上多少距离 距上多少距离
绝对定位例子:
CSS代码:
.a,.b,.c{ border:1px solid #F00}
.a{ width:300px; height:50px; position:relative;}/* 设置position:relative */
.b{ position:absolute; left:0; top:0; width:100px; height:30px;}/* 设置个BOX */
.c{ position:absolute; right:5px; top:5px; height:40px; width:60px;}/* 设置2box */
DIV代码:
<div class="a">
<div class="b">内容1</div>
<div class="c">内容2</div>
</div>
全页代码及演示:
CSS绝对定位示例教程截图
我们看见下面的显示边距区内的样式已经和之前我们设置BOX实验已经不同,DW里是实线,而上次是虚线,这样我们拿到一个DIV CSS网页一看即可知道他运用此position属性。当然如果浏览器查看,此区域线是会消失的
如:
CSS绝对定位在浏览器截图