css2024

1 :has() Selector

    <ul>
        <li>
          <label> <input type="radio" name="source" />谷歌</label>
        </li>
        <li>
          <label> <input type="radio" name="source" />口碑</label>
        </li>
        <li>
          <label> <input type="radio" name="source" />其他</label>
        </li>
      </ul>

  <style>
    ul li input:checked {
      accent-color: #f806e4;
    }
    ul li:has(input:checked) {
      border: 2px solid #f806e4;
    }
  </style>

2: Container Queries

<!-- HTML code structure of individual component -->

<section id="featured-course" class="courses">
  <div class="course">
    <div class="course-card">
      <img src="./images/gpt-thumb.webp" alt="" class="course-thumb" />
      <div class="course-info">
        <p class="course-name">ChatGPT - The Complete Guide</p>
        <p>
          10x your productivity by using ChatGPT OpenAI APIs efficiently.
          Learn Midjourney, prompt engineering, AutoGPT and more!
        </p>
      </div>
    </div>
  </div>
</section>

 <style>
    .courses {
      display: flex;
      gap: 10px;
      justify-content: center;
      .course {
        container-type: inline-size;
        width: 100%;
        .course-card {
          display: flex;
          flex-direction: column;
          align-items: center;
          background: #620b79;
          border-radius: 5px;
          box-shadow: 1px 1px 1px #333333;
          width: 100%;
          height: 100%;
        }
      }
    }

    .course-thumb {
      max-width: 100%;
    }
    @container (min-width: 400px) {
      .course-card {
        flex-direction: row;
        align-items: normal;
      }

      .course-thumb {
        width: 50%;
      }
    }
  </style>

3: CSS Nesting

.container {
  max-width: 800px;
  margin: auto;
  background-color: #f5f5f5;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.container h1 {
  color: #1a237e;
}

.container p {
  color: #757575;
}

.container {
  max-width: 800px;
  margin: auto;
  background-color: #f5f5f5;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;

  h1 {
    color: #1a237e;
  }

  p {
    color: #757575;
  }
}

4: New Value for text-wrap: balance

.balanced-text h2 {
  color: #ffa726;
  text-wrap: balance;
}

.unbalanced-text h2 {
  color: #fc01da;
}

5:The :focus-visible Pseudo Class

        <main>
          <h1>Focus-visible Demo</h1>
          <button>Click Me</button>
          <input type="text" placeholder="Type here..." />
          <a href="#">Learn More</a>
        </main>

    button:focus-visible,
    input:focus-visible,
    a:focus-visible {
      border-color: #1e88e5;
      box-shadow: 0 0 3px 2px #1e88e580;
    }

相关推荐

  1. css2024

    2024-07-19 16:56:01       28 阅读
  2. 2024.2.3日总结(animate.css

    2024-07-19 16:56:01       53 阅读
  3. 2024前端面试准备-HTML&CSS

    2024-07-19 16:56:01       33 阅读
  4. 2024前端面试真题【CSS篇】

    2024-07-19 16:56:01       38 阅读
  5. 2024前端面试准备之CSS篇(二)

    2024-07-19 16:56:01       67 阅读
  6. 2024前端面试准备之CSS篇(一)

    2024-07-19 16:56:01       64 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 16:56:01       171 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 16:56:01       189 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 16:56:01       157 阅读
  4. Python语言-面向对象

    2024-07-19 16:56:01       170 阅读

热门阅读

  1. Jangow

    Jangow

    2024-07-19 16:56:01      30 阅读
  2. new一个对象的具体步骤

    2024-07-19 16:56:01       30 阅读
  3. Hive 的 classpath 简介

    2024-07-19 16:56:01       29 阅读
  4. ArcGIS Pro SDK (九)几何 7 多点

    2024-07-19 16:56:01       31 阅读
  5. 网络安全相关竞赛比赛

    2024-07-19 16:56:01       35 阅读
  6. Open3D点云配准介绍-点云之间进行配准

    2024-07-19 16:56:01       33 阅读
  7. windows关闭双击过后的jar 包

    2024-07-19 16:56:01       35 阅读
  8. windows下flutter国内镜像恢复成外网链接

    2024-07-19 16:56:01       24 阅读
  9. Amazon Bedrock 常用场景及 Python 实现

    2024-07-19 16:56:01       28 阅读