首页 > 其他分享 >CSS中所有选择器

CSS中所有选择器

时间:2023-04-09 14:12:51浏览次数:31  
标签:blue color 所有 class green background 选择器 CSS

测试CSS中所有选择器

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
<!--属性选择器-->
         h1{
            color: black;
        }
<!--class选择器-->
        .wwwwwww{
         color: blue;
        }

<!--id选择器-->
        #rrrrrr{
        color: green;
        }

<!--       后代选择器,所有子类选择器-->
    body p{
         background: red;
        }
<!--子类选择器,后一代选择器-->
    li>p{
       background: green;
    }
<!--兄弟选择器,向下选择一个-->
    .active + p{
      background: green;
    }
<!--兄弟选择器,向下选择所有的兄弟-->
.active~p{
      background: blue;
    }
<!--伪类选择器-->
    ul li:first-child{
        background: yellow;
    }
        
    a{
    background: blue;
    }
<!--属性选择器-->
<!--选择所有有id的a标签-->
    a[id]{
    background: yellow;
    }
<!--选择id为tttt的a标签-->
     a[id=tttt]{
    background: green;
    }
<!--选择class内有itemes的a标签-->
    a[class*=itemes]{
    background: red;
    }
<!--选择class以ttt开头的a标签-->
    a[class^=ttt]{
    background: #64ffff;
    }
<!--选择class以rrr结尾的a标签-->
    a[class$=rrr]{
    background: #23f133;
    }
    </style>
</head>
<body>
<a class="items classes mytest" id="tttt">asdfafasd</a>
<a class=" classes mytest" id="tttt55">asdfafasd666</a>
<a class="items classes mytest" id="tttt5555">asdfafasd8888</a>
<a class="itemes classes mytest">asdfafasd7676767</a>
<a class="tttttitems classes mytestes">asdfafasd76767678787</a>
<a class="itemes classes mytest">aaaaaaaaaass</a>

<a class="tttttitems classes mytestrrr">asdfafasd76767678787</a>
<a>ddddddddddddd</a>
<h1 class="wwwwwww">asdfffffffff</h1>
<h1 id="rrrrrr">222222</h1>
<h1>333333</h1>
<h1>444444</h1>
<h1>555555</h1>
<p>p1</p>
<p>p2</p>
<p>p3</p>
<ul>
    <li><p >p4</p></li>
    <li><p>p5</p></li>
    <li><p>p6</p></li>
</ul>
<p class="active">p7</p>
<p>p8</p>
<p>p9</p>
<p>p71</p>
<p>p811</p>
<p>p91</p>
</body>

 

标签:blue,color,所有,class,green,background,选择器,CSS
From: https://www.cnblogs.com/studymyself/p/17300258.html

相关文章

  • CSS3边框属性 阴影 box-shadow 属性
    box-shadow属性各个参数的含义值说明h-shadow必需的。水平阴影的位置。允许负值 v-shadow必需的。垂直阴影的位置。允许负值blur可选。模糊距离,使用类似高斯模糊的算法将阴影进行模糊处理,模糊后阴影的范围将扩大,扩大的距离为blur/2spread可选。阴影的大小:在原......
  • css Position用法
    相对位置和绝对位置现有3个div如下<style>.brother{width:200px;height:200px;background-color:yellow;}.father{width:200px;height:200px;background......
  • css浮动问题
    引出问题这是一个正常的排版代码如下<style>.father{width:200px;border:1pxsolidred;}.son{width:100px;height:100px;background-color:blue;}</st......
  • 遍历JsonObject 所有的key和value封装到两个list中
    可以使用main方法测试体验效果publicstaticvoidmain(String[]args){StringoriginalStr="{\"code\":200,\"msg\":\"success\",\"data\":{\"realName\":\"超级管理员\",\"defaultApp\":......
  • Day03 - CSS 变量
    作者:©liyuechun实现效果用JavaScript和CSS3实现拖动滑块时,实时调整图片的内边距、模糊度、背景颜色,同时标题中JS两字的颜色也随图片背景颜色而变化。涉及特性:rootvar(--xxx):CSS变量(CSSVariables)filter:blur()事件change、mousemoveHTML源码<h2>UpdateCSSVariables......
  • Day02 - JavaScript + CSS Clock
    Day02-JavaScript+CSSClock作者:©liyuechun简介第二天的练习是用JS+CSS模拟时钟效果。效果如下:实现以上模拟时钟的效果,大致思路和解决方案如下:分别获取到当前时间的时、分、秒。通过时分秒对一圈360度,进行映射,确定每一个指针所需旋转的角度。通过CSS的transform:rotate(deg),......
  • tailwindcss 安装
    #tailwindcsspnpmitailwindcsspostcssautoprefixer#生成tailwindcss配置文件npxtailwindcssinit-p//tailwind.config.jsmodule.exports={...content:['./public/**/*.html','./src/**/*.{js,jsx,ts,tsx,vue}'],}#新建/src/styl......
  • css:writing-mode控制文字水平排布或垂直排布
    writing-mode属性定义了文本水平或垂直排布以及在块级元素中文本的行进方向。文档https://developer.mozilla.org/zh-CN/docs/Web/CSS/writing-mode语法/*关键字值*/writing-mode:horizontal-tb;writing-mode:vertical-rl;writing-mode:vertical-lr;效果在线demo......
  • css边距合并的问题
    上下两个盒子边距合并问题<style>*{margin:0px;padding:0px;}div{width:100px;height:100px;}.top{background-color:red;margin-b......
  • CSS标准盒子模型与怪异盒子模型
    <style>*{margin:0;padding:0;}div{/*宽高改变的是内容大小*/width:200px;height:200px;}/*w3c标准盒子:盒子的总大小=内容+内边距+边框+外边距*//*只要改变内容,内边距,外边距,边框,盒子都......