前端——CSS知识点

来源:互联网 发布:mac windows虚拟机 编辑:程序博客网 时间:2024/06/05 22:43
1、内联式css样式,直接写在现有的HTML标签中   例如:<p style="color:red;font-size:12px">这里文字是红色。</p>


2、嵌入式css样式,写在当前的文件中<style type="text/css"></style>标签之间


3、外部式css样式,写在单独的一个文件中<link href="base.css" rel="stylesheet" type="text/css"/ >
三种方法的优先级::内联式 > 嵌入式 > 外部式


伪类选择器:a:hover{color:red;}
上面一行代码就是为 a 标签鼠标滑过的状态设置字体颜色变红。这样就会使第一段文字内容中的“胆小如鼠”文字加入鼠标滑过字体颜色变为红色特效。


文字排版--字体:body{font-family:"Microsoft Yahei";}


文字排版--字号、颜色:body{font-size:12px;color:#666}


文字排版--粗体:p span{font-weight:bold;}


文字排版--斜体:p a{font-style:italic;}


文字排版--下划线:p a{text-decoration:underline;}


文字排版--删除线: .oldPrice{text-decoration:line-through;}


段落排版--缩进:p{text-indent:2em;}


段落排版--行间距(行高):p{line-height:2em;}


段落排版--中文字间距、字母间距:h1{
    letter-spacing:50px;
}
单词间距设置:h1{
    word-spacing:50px;
}


段落排版--对齐:h1{
    text-align:center/right/left;
}
0 0