第1篇:CSS基本选择器(CSS) 您所在的位置:网站首页 css格式化网页的三种方式有哪些 第1篇:CSS基本选择器(CSS)

第1篇:CSS基本选择器(CSS)

2024-07-17 11:51| 来源: 网络整理| 查看: 265

css介绍

1、CSS(层叠样式表)是一种格式化网页的标准方式,用于设置网页的样式,并允许样式信息与网页内容分离的一种技术。

2、好处:

(1)将格式和结构分离

(2)精确控制页面布局

(3)制作体积更小、下载更快的网页

(4)可以实现许多网页同时更新

基本选择器

元素选择器

元素选择器是最常用的一种选择器,元素选择器声明了网页中所有相同元素的显示效果

基本语法:HTML元素{属性1:属性值1;属性2:属性值2;...}

类选择器

对相同元素的某些元素做特殊效果设置。

基本语法:.类选择器名{属性1:属性值1;属性2:属性值2;...}

说明:类选择器名称的第1个字符不能使用数字;类选择器的优先级高于元素选择器,所以相同属性的样式,类选择器的样式会覆盖元素选择器的样式,

类名在HTML页面中可以重名。

ID选择器

 ID名称站在HTML页面中必须唯一。

基本语法:#id选择器名{属性1:属性值1;属性2:属性值2;...}

说明:id选择器名称的第一个字符不能使用数字;id选择器名不能有空格。

例子

css基本选择器的使用 *{ margin:0px; padding:0px; } p{color: goldenrod;} h3{color: blueviolet;} h4{color: rosybrown;} .txt01{ color: #8A2BE2; } .txt02{ color: tomato; } .txt03{ color: saddlebrown; } .txt04{ color: sienna; } #txt01{ text-align: center; color: rosybrown; } #txt02{ text-align: center; font: 楷体; color: goldenrod; } #txt03{ font: 楷体; font-size: 22px; align-content: center; text-align: center; color: chocolate; margin: auto; } #txt04{ text-align: center; color: forestgreen; } this is the head title! this is the second title!

古诗词鉴赏

欢迎来到类选择器 数据分析总结表 01 02 03 04 05 12.9 12.4 13.9 12.3 11.9

分析结果

第一期 第二期 第三期 第四期 第五期 34.90 46.97 35.15 45.33 50.01 34.90 46.97 35.15 45.33 50.01

总结分析:

 

通用选择器

通用选择器用通配符“*”表示,可以选择文档中的所有元素。通用选择器主要用于重置文档各元素的默认样式,一般用来重置文档元素的内、外边距。

基本语法:*{属性1:属性值1;属性2:属性值2;...}

常用:*{margin:0px;padding:0px;}//重置文档所有元素的内、外边距

通用选择器 *{ text-align: center; font-size: 24px; color: chocolate; font: "楷体"; margin: auto; }

欢迎来到通用选择器页面

01 02 03 04 05 12.9 12.4 13.9 12.3 11.9

伪类选择器

伪类选择器的使用 a:link{ color: green; text-decoration: none; /*无下划线*/ } a:visited{ color: darkblue; } a:hover{ color: #D2691E; } a:active{ color: mediumvioletred; } input:focus{ background: #BC8F8F; } p:first-child{ font-size: 30px; color: firebrick; } li:first-child{ color: slateblue; } q:lang(no){ color: cornflowerblue; font-size: 30px; } q:lang(zh){ color: darkmagenta; font-size: 30px; } html基础-图片标签 html基础-列表标签 htnl基础-表格 html基础-表单 姓名: 性别:男 女

reckoninterpre

thinkinterpre

consider

deem

vitical impotant essential,paramount

reckon

think

consider

deem

伪元素选择器

伪元素选择器的使用 p:first-letter{ font-size: 22px; color: saddlebrown; text-decoration:underline; } /*p:line{ color: slateblue; } p:before{ content: url(../img/bg.JPG); } p:after{ content: url(../img/bg.JPG); }*/

伪元素选择器:当选择器是类选择器时,为了限定某类元素,也可以在类选择器名前加上元素名,即将选择器名写成:元素名.类选择器名。

伪类选择器说明:当选择器是类选择器时,为了限定某类元素,也可以在类选择器名前加上元素名,即将选择器名写成:元素名.类选择器名。

层叠样式表(Casading Style Sheet)是一种格式化网页的标准方式,用于设置网页的样式,并允许样式信息与网页内容分离的一种技术。

元素选择器是最常用的一种选择器,元素选择器声明了网页中所有相同元素的显示效果



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有