HTML与CSS学习 day3

  • 体验css语法规范
<style>
        p{
            color: red;
            font-size: 20px;
        }
    </style>
    
<p>学习前端第三天 我很快乐</p>
  • 标签选择器
 <style>
    p {
        color: green;
    }
    div {
        color: brown;
    }
</style>
<body>
    <p>男生</p>
    <p>男生</p>
    <p>男生</p>
    <div>女生</div>
    <div>女生</div>
    <div>女生</div>
</body>
  • 类选择器
    首先在需要修改的区域 添加一个class属性 class="类名"。其次在
<style> 
 .类名 {
     修改的内容
      }
 </style>

在这里插入图片描述

  <style>
        .red {
            color: red;
        }

        .pp {
            color: green;
        }

        .cc {
            color: indigo;
        }
    </style>
</head>

<body>
    <ul>
        <li class="red">只只</li>
        <li class="pp">只只只</li>
        <li class="cc">只只只只</li>
    </ul>
</body>
  • 多类名的使用
    类名之间必须使用空格
<style>
   .box{
       width: 100px;
       height: 100px;
   }
   .red{
       background-color: red;
   }
   .green{
       background-color: green;
   }
</style>
<body>
    <div class="box red"></div>
    <div class="box green"></div>
    <div class="box red"></div>  
</body>
  • id选择器
    cssid#定义 id只能调用一次
<style>
    #red {
        color: red;
    }
</style>
<body>
  <div id="red">ios</div>  
</body>

id选择器和类选择器的区别
在这里插入图片描述

  • 通配符选择器
    *可以对所有标签修改样式 例如 div span li 等等
<style>
    * {
        color: red;
    }
    /* *可以对所有标签修改样式 例如 div span li 等等 */
</style>

<body>
    <div>一只咸鱼</div>
    <span>一只咸鱼</span>
    <ul>
        <li>一只咸鱼</li>
    </ul>
    <ol>
        <li>一只咸鱼</li>
    </ol>
</body>

对比

在这里插入图片描述

  • css字体系列
font-family
<style>
      body{
          font-family: '宋体';
      } 
  </style>
<body>
    <h4>静夜思</h4>
    <p>床前明月光</p>
    <p>疑是地上霜</p>
    <p>举头望明月</p>
    <p>低头思故乡</p>
</body>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值