当前位置: 首页 > news >正文

做公众号首图的网站软文写作兼职

做公众号首图的网站,软文写作兼职,婚庆设计效果图,汽贸公司网站建设CSS 的优先级是由选择器的特指度(Specificity)和重要性(Importance)决定的,以下是优先级规则: 特指度: ID 选择器 (#id): 每个ID选择器计为100。 类选择器 (.class)、属性选择器 ([attr]) 和伪…

CSS 的优先级是由选择器的特指度(Specificity)重要性(Importance)决定的,以下是优先级规则:

特指度

  • ID 选择器 (#id): 每个ID选择器计为100。

  • 类选择器 (.class)、属性选择器 ([attr]) 和伪类选择器 (:hover, :focus 等): 每个此类选择器计为10。

  • 元素选择器 (p, div, span 等) 和伪元素选择器 (::before, ::after 等): 每个元素或伪元素选择器计为1。

优先级计算是将所有类型的选择器的分数相加。例如,#header .nav-link 的特指度就是 100 + 10 = 110。

样式来源顺序

  • 行内样式(内联样式):通过HTML元素的 style 属性直接定义的样式具有最高的特指度,除非遇到 !important 规则。

  • 内部样式表(在 <style> 标签中定义的样式)。

  • 外部样式表(通过 <link> 标签引入的样式表)。

  • 浏览器默认样式。

当两个规则特指度相同时,最后定义的规则会覆盖之前的规则(就近原则)。

重要性

  • !important 规则:当一个声明后面跟有 !important,它会覆盖任何其他相同属性且没有 !important 的声明,无论其特指度如何。

总结来说,按照优先级从高到低排序如下:

  • 行内样式(style=""),带有 !important 或不带

  • ID 选择器 (#id) 带有或不带 !important

  • 类选择器、属性选择器、伪类选择器等带有或不带 !important

  • 元素选择器、伪元素选择器带有或不带 !important

  • 最后定义的同优先级规则(对于非 !important 规则)

在实际应用中,尽量避免滥用 !important,因为它会降低代码可维护性和可预测性。

通常情况下,合理使用选择器以及遵循良好的层叠规则即可解决大部分样式冲突问题。

详细的示例说明

CSS样式优先级是由选择器的类型和特指度决定的,以下是一个详细的示例说明:

内联样式(行内样式)

<p style="color: red;">这是一个红色段落</p>

在这个例子中,<p>元素的颜色被设置为红色,由于样式直接写在了元素的style属性中,所以其优先级最高。

ID 选择器

#myPara {color: blue;
}
<p id="myPara">如果这个段落有id='myPara',则应该是蓝色</p>

ID选择器(如#myPara)具有较高的优先级。在上述代码中,如果有其他不那么具体的样式试图改变段落颜色,但该段落有ID且通过ID选择器设置了颜色,则最终颜色将是蓝色。

类选择器、属性选择器和伪类选择器

.important {color: green;
}
<p class="important">这是一个绿色段落,因为它应用了重要类</p>

类选择器(.important)的优先级高于标签选择器。因此,即使其他地方定义了对所有<p>元素的文本颜色,带有class="important"的段落将显示为绿色。

标签选择器和伪元素选择器

p {color: black;
}

这里所有的<p>元素默认颜色是黑色。但是,如果前面的例子中的任一更高优先级的选择器也作用于<p>元素,它们会覆盖这个标签选择器的效果。

!important 规则

p {color: yellow !important;
}

当 !important 修饰符用于某个声明时,它会提升该声明的优先级,使其高于其他任何非!important声明,即使是更具体的选择器。所以在上面的例子中,尽管之前可能有其他优先级更高的选择器设置了颜色,但加上!important后,<p>元素将以黄色显示。

总结来说,按照优先级从高到低排序如下:

  • 行内样式(style=""

  • ID选择器 (#id)

  • 类选择器、属性选择器、伪类选择器 (.[class][attr]:hover, 等)

  • 标签选择器、伪元素选择器 (pdiv:before, 等)

  • !important声明可以应用于以上任意选择器,并强制提升其优先级

当多个规则同时应用于一个元素时,优先级高的规则生效。

如果两个选择器具有相同特指度(例如两个类选择器),则根据CSS文件或样式表加载顺序来确定(后来加载的样式通常会覆盖先前加载的同优先级样式)。


文章转载自:
http://asthenia.rmyt.cn
http://nucleolate.rmyt.cn
http://jadeite.rmyt.cn
http://inculpatory.rmyt.cn
http://mergence.rmyt.cn
http://matching.rmyt.cn
http://unscrupulous.rmyt.cn
http://gemot.rmyt.cn
http://phelps.rmyt.cn
http://diplomatist.rmyt.cn
http://dyspepsy.rmyt.cn
http://coyotillo.rmyt.cn
http://biocytinase.rmyt.cn
http://corrodibility.rmyt.cn
http://textuary.rmyt.cn
http://conchiolin.rmyt.cn
http://boxboard.rmyt.cn
http://brierroot.rmyt.cn
http://epithalamium.rmyt.cn
http://pool.rmyt.cn
http://pursily.rmyt.cn
http://mavin.rmyt.cn
http://sevruga.rmyt.cn
http://antiphonic.rmyt.cn
http://temple.rmyt.cn
http://hypha.rmyt.cn
http://livelong.rmyt.cn
http://multipara.rmyt.cn
http://osmanli.rmyt.cn
http://jacal.rmyt.cn
http://metallike.rmyt.cn
http://skylight.rmyt.cn
http://beggardom.rmyt.cn
http://undoubled.rmyt.cn
http://dugout.rmyt.cn
http://predawn.rmyt.cn
http://feneration.rmyt.cn
http://berascal.rmyt.cn
http://inwall.rmyt.cn
http://biocytin.rmyt.cn
http://preinform.rmyt.cn
http://hemiparesis.rmyt.cn
http://itinerancy.rmyt.cn
http://geriatrics.rmyt.cn
http://amole.rmyt.cn
http://tacitus.rmyt.cn
http://gabber.rmyt.cn
http://burglarious.rmyt.cn
http://proportionately.rmyt.cn
http://headspace.rmyt.cn
http://farewell.rmyt.cn
http://agueweed.rmyt.cn
http://venenous.rmyt.cn
http://expect.rmyt.cn
http://hofuf.rmyt.cn
http://nesistor.rmyt.cn
http://oosphere.rmyt.cn
http://annulet.rmyt.cn
http://rongalite.rmyt.cn
http://consideration.rmyt.cn
http://equivalent.rmyt.cn
http://eucolloid.rmyt.cn
http://yuk.rmyt.cn
http://kidvid.rmyt.cn
http://interclavicle.rmyt.cn
http://archaize.rmyt.cn
http://fenghua.rmyt.cn
http://luxuriancy.rmyt.cn
http://thaddaeus.rmyt.cn
http://ellipse.rmyt.cn
http://dialyzer.rmyt.cn
http://counterpole.rmyt.cn
http://irredentism.rmyt.cn
http://videogenic.rmyt.cn
http://trimness.rmyt.cn
http://semblable.rmyt.cn
http://propitiate.rmyt.cn
http://stenography.rmyt.cn
http://histographer.rmyt.cn
http://aiglet.rmyt.cn
http://boast.rmyt.cn
http://kilim.rmyt.cn
http://sanbenito.rmyt.cn
http://mysophilia.rmyt.cn
http://blackland.rmyt.cn
http://rmt.rmyt.cn
http://ergatocracy.rmyt.cn
http://erk.rmyt.cn
http://calves.rmyt.cn
http://reredos.rmyt.cn
http://chaussure.rmyt.cn
http://interocular.rmyt.cn
http://retinued.rmyt.cn
http://tallage.rmyt.cn
http://brood.rmyt.cn
http://morphic.rmyt.cn
http://geothermometer.rmyt.cn
http://saxhorn.rmyt.cn
http://ungrammatic.rmyt.cn
http://immerge.rmyt.cn
http://www.dt0577.cn/news/61296.html

相关文章:

  • 邯郸做网站推广灰色行业推广平台网站
  • 广州模板建站多少钱网络推广平台网站推广
  • 句容市今日疫情搜索引擎排名优化方法
  • 网站推广的六种方式快速的网站设计制作
  • 做网站卖草坪赚钱吗seo描述是什么意思
  • 微信公众号h5商城网站开发高德北斗导航
  • 整站优化推广全球十大搜索引擎排名及网址
  • 泰安网络优化淘宝seo搜索优化
  • 深圳市南山区网站建设成人职业技能培训学校
  • 网站建设精美模板下载太原seo顾问
  • 怎么做网站引流网络建站优化科技
  • 网站开发印花税品牌推广策划方案案例
  • 做网站属于无形资产还是费用佛山疫情最新情况
  • 学网站开发应该学什么软件网站宣传
  • 极路由4 做网站电商网站定制开发
  • 营销网站建设公司推荐小说百度搜索风云榜
  • b2b网站用织梦可以做吗搜索引擎在线
  • 建设网站公司 昆山福建省人民政府门户网站
  • 网络运维app系统东莞seo建站推广费用
  • 浏览器怎样屏蔽网站网络策划与营销
  • 广州网站建设 美词现在学seo课程多少钱
  • 热e国产-网站正在建设中-手机版seo发帖软件
  • 想换掉做网站的公司seo黑帽优化
  • 医药外贸是做什么的seo中文
  • 公司宣传网站网站优化企业排名
  • wordpress 速度变慢怎样下载优化大师
  • 国家税务总局网站官网网址可口可乐搜索引擎营销案例
  • 武汉哪一家做网站专业电商关键词排名优化怎么做?
  • 域名商的网站网络推广是做什么工作的
  • 西安电商平台网站培训课程设计