2023CSS 的作用:目标选择器

 所属分类:web前端开发

 浏览:32次-  评论: 0次-  更新时间:2023-09-22
描述:更多教程资料进入php教程获得。 使用 CSS :target 选择器通过 CSS 突&#20986...
更多教程资料进入php教程获得。

CSS 的作用:目标选择器

使用 CSS :target 选择器通过 CSS 突出显示活动的 HTML 锚点。

示例

您可以尝试运行以下代码来实现 :target 选择器

现场演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         :target {
            border: 2px solid #D4D4D4;
            background-color: orange;
            color: white;
         }
      </style>
   </head>
   <body>
      <p>Click any of the subject below.</p>
      <p><a href = "#tut1">Maths</a></p>
      <p><a href = "#tut2">Java</a></p>
      <p><a href = "#tut3">C++</a></p>
      <p><a href = "#tut4">C</a></p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p>This is demo text.</p>
      <p id = "tut1"><b>Maths Tutorial</b></p>
      <p id = "tut2"><b>Java Tutorial</b></p>
      <p id = "tut3"><b>C++ Tutorial</b></p>
      <p id = "tut4"><b>C Tutorial</b></p>
   </body>
</html>
 标签:
积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!