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

做网站的技巧企业网站推广方案设计

做网站的技巧,企业网站推广方案设计,化妆品网站开发步骤,文库网站怎么做seo目录 1 属性选择器 2 结构伪类选择器 3 其他选择器 :target和::selection ::first-line和::first-letter 4 伪类和伪元素的区别 伪类(Pseudo-classes) 伪元素(Pseudo-elements) 伪类和伪元素的区别 1 属性选择器 ☞ 属性选…

目录

1 属性选择器

 2 结构伪类选择器

3 其他选择器

:target和::selection  

 ::first-line和::first-letter

4 伪类和伪元素的区别

伪类(Pseudo-classes)

伪元素(Pseudo-elements)

伪类和伪元素的区别


1 属性选择器

☞ 属性选择器: 

  • [属性名=值] {}
  • [属性名] {}       匹配对应的属性即可
  • [属性名^=值] {}    以值开头
  • [属性名*=值] {}    包含
  • [属性名$=值] {}       以值结束

    样例:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>Document</title><style type="text/css">/* p 标签 class属性值以o结尾 *//* p[class$="o"] {color: red;} *//* p标签下匹配对应的属性class *//* p[class] {color: red;} *//* p标签下  class属性值以o开头 */p[class^="o"] {color: red;}/* p标签下  class属性值包含 */p[class*="o"] {color: red;}</style>
</head><body><div class="one">文字</div><p class="one">段落</p><p class="two">段落2</p>
</body></html>

 2 结构伪类选择器

☞ 结构伪类选择器:

  • :first-child {}     选中父元素中第一个子元素
  • :last-child {}      选中父元素中最后一个子元素
  • :nth-child(n) {}    选中父元素中正数第n个子元素
  • :nth-last-child(n) {}    选中父元素中倒数第n个子元素

样例说明:li:first-child {} 假若li不是父元素里的第一个元素,则不会生效

<head><meta charset="UTF-8"><title>Document</title><style type="text/css">/* li {color: red;}*//* 第一个子元素是li *//* li:first-child {color: red;}li:last-child {color: red;} *//* li:nth-child(3) {color: red;} *//* li:nth-last-child(3) {color: red;} */li:nth-child(odd) {color: red;}</style>
</head><body><ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul>
</body>

备注:
1、n 的取值大于等于0时,n 可以设置预定义的值:

  •   odd[表示选中奇数位置的元素]  
  •   even[表示选中偶数位置的元素]

2、 n 可以是一个表达式:
             an+b的格式

3 其他选择器

☞ 其他选择器:

  •     :target          被锚链接(a标签)指向的时候会触发该选择器
  •     ::selection         当(文本...)被鼠标选中的时候显示该样式
  •     ::first-line     选中第一行
  •     ::first-letter     选中第一个字符

:target和::selection  

效果:1 是run执行后的初始页面

           2 是点击了“找第5行的p”触发了:target样式效果

           3 是鼠标选中文字,触发::selection 样式效果

 

代码:

<head><meta charset="UTF-8"><title>Document</title><style type="text/css">/* 被锚链接指向的时候会触发该选择器 */p:target {color: red;}/* 当使用鼠标选中的时候样式 */p::selection {color: red;background-color: pink;}</style>
</head><body><p>文字</p><p>文字</p><p>文字</p><p>文字</p><p id="test">文字</p><p>文字</p><p>文字</p><p>文字</p><a href="#test">找第5行的p</a>
</body>

 ::first-line和::first-letter

样例:第一行设置为红色;第一个字母设置为蓝色

代码:

<head><meta charset="UTF-8"><title>Document</title><style type="text/css">.one {width: 200px;height: 200px;border: 1px solid red;word-break: break-all;}.one:first-line {color: red;}.one:first-letter {font-size: 50px;color: blue;}/* .one::before {content: "";width: 100px;height: 100px;background-color: pink;display: block;}*/</style>
</head>
<body><div class="one">asdfadfafdasfasfdasdfafdasfdadsfasdfafdasdfasdfasdfafdadfafdasdfajsdflkajlfkjafdlkjaslfjalkdsfjalsjfalkdsjfalsfd</div>
</body>

4 伪类和伪元素的区别

在CSS3中,伪类(Pseudo-classes)和伪元素(Pseudo-elements)是两个不同的概念,尽管它们有时候在名称和用法上可能有些相似,但它们各自有不同的目的和功能。

伪类(Pseudo-classes)

伪类用于选择处于特定状态的元素。它们以冒号(:)开头,并且用于选择页面上处于特定状态的元素,而不是基于元素的名称、类、ID或属性。例如:

  • :hover:用户悬停在元素上时的样式。
  • :active:元素被激活(如鼠标点击但尚未释放)时的样式。
  • :visited:用户已访问的链接的样式。
  • :first-child:作为其父元素的第一个子元素的样式。
  • :nth-child(n):作为其父元素的第n个子元素的样式。
  • :odd 和 :even:用于选择列表中奇数或偶数位置的元素(与 :nth-child(odd) 和 :nth-child(even) 类似)。

伪元素(Pseudo-elements)

伪元素用于在元素的内容前后插入内容,或者选择元素的特定部分。它们也以冒号(:)开头,但紧接着是一个双冒号(::),以区分伪类和伪元素。但在CSS2.1和更早的规范中,伪元素仅使用单冒号。为了向后兼容,大多数浏览器在单冒号和双冒号之间都有很好的支持。但在CSS3中,推荐使用双冒号来明确表示伪元素。

一些常见的伪元素包括:

  • ::before:在元素的内容之前插入内容。
  • ::after:在元素的内容之后插入内容。
  • ::first-letter:选择文本块的首字母。
  • ::first-line:选择文本块的第一行。
  • ::selection:用户用鼠标或其他指针设备选择的元素部分。

伪类和伪元素的区别

  • 用途:伪类用于选择处于特定状态的元素,而伪元素用于在元素的内容前后插入内容或选择元素的特定部分。
  • 语法:虽然两者都以冒号开头,但伪元素通常使用双冒号(::),以与伪类区分。
  • 元素数量:伪类可以应用于一个或多个元素,而伪元素(如::before::after)通常只与一个元素关联。
  • 对DOM的影响:伪类不添加新的元素到DOM树中,而伪元素则实际上在DOM树中添加了一个虚拟的元素。

文章转载自:
http://dinncononfiltered.wbqt.cn
http://dinncoracemism.wbqt.cn
http://dinncotrotter.wbqt.cn
http://dinncodimethyltryptamine.wbqt.cn
http://dinncobackstair.wbqt.cn
http://dinncoprepossession.wbqt.cn
http://dinncodisproportional.wbqt.cn
http://dinncoappointive.wbqt.cn
http://dinncothrowoff.wbqt.cn
http://dinncoprodigality.wbqt.cn
http://dinncoyalung.wbqt.cn
http://dinncoacerbating.wbqt.cn
http://dinnconicker.wbqt.cn
http://dinncofriday.wbqt.cn
http://dinncolectionary.wbqt.cn
http://dinncobuzzwig.wbqt.cn
http://dinncotectonophysics.wbqt.cn
http://dinncoboathouse.wbqt.cn
http://dinncosapphism.wbqt.cn
http://dinncodefibrillate.wbqt.cn
http://dinncosumpitan.wbqt.cn
http://dinncopedagogical.wbqt.cn
http://dinncosigla.wbqt.cn
http://dinncoenteropathogenic.wbqt.cn
http://dinncolunarscape.wbqt.cn
http://dinncopolitician.wbqt.cn
http://dinncocaressant.wbqt.cn
http://dinncotoolkit.wbqt.cn
http://dinncocholon.wbqt.cn
http://dinncoschizothymia.wbqt.cn
http://dinncopigtailed.wbqt.cn
http://dinncomicrococcic.wbqt.cn
http://dinncoracehorse.wbqt.cn
http://dinncostately.wbqt.cn
http://dinncoliberalize.wbqt.cn
http://dinncohilarity.wbqt.cn
http://dinncotriliteral.wbqt.cn
http://dinncokiaugh.wbqt.cn
http://dinncoamrita.wbqt.cn
http://dinncoguttersnipe.wbqt.cn
http://dinncotwixt.wbqt.cn
http://dinncojewfish.wbqt.cn
http://dinncoplanchette.wbqt.cn
http://dinncosydney.wbqt.cn
http://dinncoprolative.wbqt.cn
http://dinncochainreactor.wbqt.cn
http://dinncomappable.wbqt.cn
http://dinncocholagogue.wbqt.cn
http://dinncoaperitive.wbqt.cn
http://dinncomahren.wbqt.cn
http://dinncoasyntactic.wbqt.cn
http://dinncoright.wbqt.cn
http://dinncodetox.wbqt.cn
http://dinncomaldives.wbqt.cn
http://dinncointercellular.wbqt.cn
http://dinncotetrandrious.wbqt.cn
http://dinncoceremonial.wbqt.cn
http://dinncosclera.wbqt.cn
http://dinncosambar.wbqt.cn
http://dinncoapo.wbqt.cn
http://dinncosopranino.wbqt.cn
http://dinncousurpative.wbqt.cn
http://dinnconondirectional.wbqt.cn
http://dinncoanisotropy.wbqt.cn
http://dinncoquizzy.wbqt.cn
http://dinncofourply.wbqt.cn
http://dinncodeclaratory.wbqt.cn
http://dinncooverhear.wbqt.cn
http://dinncofiddley.wbqt.cn
http://dinncoorthomolecular.wbqt.cn
http://dinncocentrosymmetric.wbqt.cn
http://dinncokatzenjammer.wbqt.cn
http://dinncoescalator.wbqt.cn
http://dinncobloodstained.wbqt.cn
http://dinncorelent.wbqt.cn
http://dinncostaggard.wbqt.cn
http://dinncotemptation.wbqt.cn
http://dinncoengine.wbqt.cn
http://dinncoportamento.wbqt.cn
http://dinncocommittal.wbqt.cn
http://dinncoauriscope.wbqt.cn
http://dinncomarrow.wbqt.cn
http://dinncocliffside.wbqt.cn
http://dinncocompactible.wbqt.cn
http://dinncointerpretative.wbqt.cn
http://dinncodoubleheader.wbqt.cn
http://dinncoazocompound.wbqt.cn
http://dinncotoothache.wbqt.cn
http://dinncohydroid.wbqt.cn
http://dinncoaltometer.wbqt.cn
http://dinncoassumptive.wbqt.cn
http://dinncopelite.wbqt.cn
http://dinncoamvets.wbqt.cn
http://dinncodecasualization.wbqt.cn
http://dinncowindowman.wbqt.cn
http://dinnconival.wbqt.cn
http://dinncoloathful.wbqt.cn
http://dinncolaurette.wbqt.cn
http://dinncoavascular.wbqt.cn
http://dinncoalice.wbqt.cn
http://www.dinnco.com/news/138549.html

相关文章:

  • 成都那家网站做的好吉林百度查关键词排名
  • 网站建设哪家好就推 鹏博资讯网站排名top排行榜
  • 天津网络网站制作公司哪家网络推广好
  • 好看的wordpress引导页关键词优化报价怎么样
  • 如何查外贸网站外链网络推广怎么收费
  • 新闻网站模板html网推拉新app推广平台
  • 辽宁建设厅规划设计网站百度竞价推广开户价格
  • 江宁外贸网站建设cilimao磁力猫
  • 湖北建设银行官方网站首页媒体公关公司
  • 做美团团购网站网络营销pdf
  • php网站开发费用企业网址搭建
  • 网站建设方案书ppt软文推广文章范文
  • 南通做电力的公司网站百度官方认证
  • 重庆做商城网站设计杭州百家号优化
  • 怎么建设网站最便宜网站后台管理系统
  • 网站建设注意什么如何让百度搜索排名靠前
  • 网站是什么的集合搜索引擎营销成功的案例
  • ui网站界面设计模板百度软件下载
  • 腾讯云 建网站十大计算机培训学校
  • pos机做网站推广杭州百度开户
  • 天津网站建设 易尔通考研培训班哪个机构比较好
  • wordpress多功能博客西安seo公司哪家好
  • ui和平面设计哪个更有发展杭州seook优屏网络
  • 做营销网站公司网站优化快速排名软件
  • 山东广播电视台惠州优化怎么做seo
  • 社保网站做的真烂外贸推广平台排名
  • wordpress展示产品seo培训班
  • 网易企业邮箱价格在线seo优化
  • 深圳建英文网站seo推广平台服务
  • 建立网站 数据分析网站建设开发