什么是css选择器?(a css selector?)

CSS依赖于模式匹配规则来确定哪个样式应用于文档中的哪个元素。这些模式称为选择器,范围从标记名(例如,...

CSS依赖于模式匹配规则来确定哪个样式应用于文档中的哪个元素。这些模式称为选择器,范围从标记名(例如,

CSS stylesheet on a computer screen pto match paragraph tags) to very complicated patterns that match very specific parts of a document. For example, p#myid > b.highlightwould match any btag with a class of highlightthat is a child of the paragraph with the id myiA CSS selector is the part of a CSS style call that identifies what part of the web page should be styled. The selector contains one or more properties that define how the selected HTML

The CSS Selectors

There are several different types of selectors:

  • type selectors – matching a specific element
  • class selectors – matching elements with a specific class
  • ID selectors – matching the element with a specific ID
  • descendant selectors – matching elements that are descendants of a specific element
  • child selectors – matching elements that are a child of the specific element
  • universal selectors – matching any element
  • adjacent sibling selectors – matching elements immediately preceded by a specific element
  • attribute selectors – matching elements with a specific attribute or attribute value
  • pseudo-class selectors – matching elements with a specific pseudo-class
  • pseudo-element selectors – matching elements with specific pseudo-element properties

Format CSS Styles and CSS Selectors

The format of a CSS style looks like this:

selector { style property : style ; }

Separate multiple selectors that have the same style with commas. This is called selector grouping. For example:

selector1, selector2 { style property : style ; }

Grouping selectors is a shorthand mechanism to keep your CSS styles compact. The above grouping would have the same effect as:

selector1 { style property : style ; }selector2 { style property : style ; }

Always Test Your CSS Selectors

Not all older browsers support all the CSS selectors. If you are setting up CSS for use with browsers as old as IE8 or older, be sure to test your selectors in as many browsers on as many operating systems as you think might be used to access your code. If you are using CSS1, CSS2, or CSS3 selectors for use with current browsers, you should be fine.

  • 发表于 2021-09-08 11:10
  • 阅读 ( 162 )
  • 分类:数学

你可能感兴趣的文章

11 css模板网站:不要从头开始!

... 什么是css模板(a css template)? ...

  • 发布于 2021-03-15 11:20
  • 阅读 ( 581 )

创建web界面:从何处开始

... 你为什么需要它 ...

  • 发布于 2021-03-16 05:47
  • 阅读 ( 271 )

11个检查、清理和优化css文件的有用工具

... csslint有一个方便的下拉菜单,可以让您选择要检查哪些潜在错误。如果您发现自己遇到了特定的问题,您可以针对该错误检查代码。 ...

  • 发布于 2021-03-18 06:31
  • 阅读 ( 252 )

使用css格式化文档以便打印

...在页面上。要避免这种情况,只需使用针对该特定实例的选择器取消分页符,例如: ...

  • 发布于 2021-03-28 16:05
  • 阅读 ( 229 )

如何使用css选择器定位网页的一部分

...描述HTML文件的格式。每一条规则都由两部分组成:设置什么样式以及如何设置样式。第一部分使用一系列称为“选择器”的术语进行控制 ...

  • 发布于 2021-03-29 22:09
  • 阅读 ( 294 )

身份证件(id)和css中的类(class in css)的区别

...L标记。id和class是两种类型的选择器。 覆盖的关键领域 1.什么是CSS规则-定义,例2.什么是id-定义,例3.什么是类-定义,例4.id和类的区别-关键区别的比较 关键术语 类,CSS规则,ID 什么是css规则(css rules)? CSS由一组规则组成。浏...

  • 发布于 2021-06-30 21:53
  • 阅读 ( 316 )

独自创立(bootstrap)和css格式(css)的区别

...ap就是其中之一。它是一个前端框架。 覆盖的关键领域 1.什么是Bootstrap–定义,功能2.什么是CSS–定义,功能3.Bootstrap和CSS的区别–主要区别的比较 关键术语 引导、CSS、HTML 什么是独自创立(bootstrap)? Bootstrap是一个开发响应性和...

  • 发布于 2021-06-30 22:21
  • 阅读 ( 200 )

html格式(html)和css格式(css)的区别

...认为是web开发的主要三种基本语言。 覆盖的关键领域 1.什么是HTML–定义,功能2.什么是CSS–定义,功能3.HTML和CSS的区别是什么–关键区别的比较 关键术语 CSS、HTML、JavaScript 什么是html格式(html)? HTML用于创建web页面的结构。它...

  • 发布于 2021-07-01 02:33
  • 阅读 ( 244 )

如何创建网站第五部分:附加资源

...面上的一个元素,并且希望看到定义它的高级表示的CSS是什么样子的。以下是它在Chrome中的工作原理:在要检查的图元上单击鼠标右键,然后选择“检查图元”(这将在浏览器底部打开一个新的窗格,如下面的屏幕截图所示。在...

  • 发布于 2021-07-24 22:32
  • 阅读 ( 150 )

如何创建网站第二部分:样式和css

...ten inside the head), you can define styles for elements in the page using selectors. Internal stylesheets look like this: <code><style type="text/css"> h3 { color:red; font-family:Helvetica; font-size:20px; } </style>...

  • 发布于 2021-07-24 23:08
  • 阅读 ( 286 )
宏七了聚划iqy
宏七了聚划iqy

0 篇文章

相关推荐