1

Simple CQ Demo with :has()

 2 years ago
source link: https://codepen.io/una/pen/oNpoqGp
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Pen Settings

HTML Preprocessor

Add Class(es) to <html>

Stuff for <head>

0 unsaved changes
xxxxxxxxxx
<div class="container">
  <div class="card">
    <div class="visual">😎</div>
    <div class="meta">
      <h1>Card Title</h1>
      <p class="desc">Here is some optional descriptive text.</p>
    </div>
  </div>
</div>
<br/>
<div class="container">
  <div class="card">
    <div class="meta">
      <h1>Card Title</h1>
      <p class="desc">Here is some optional descriptive text.</p>
    </div>
  </div>
</div>

CSS (SCSS)

CSS (SCSS)

xxxxxxxxxx
.container {
  container: inline-size;
}
.card {
  display: grid;
}
.card:has(.visual) {
  grid-template-columns: 1fr 1fr;
}
.card:has(.visual) h1 {
  font-size: 2rem;
}
.card:not(:has(.visual)) h1 {
  font-size: 4rem;
}
@container (max-width: 400px) {
  .card:has(.visual) {
    grid-template-columns: 1fr;
xxxxxxxxxx

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK