Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
この方法は sveltejs/svelte#6969 (comment) による。 仕組み 1. Svelte では@container はSyntax Error となる 2. 外部CSS まではSvelte は関与しないので、そこに@container を書く ただし、グローバルCSS での提供となり、クラス名に配慮しなければならない また、src/Product.svelte と public/product.css と二元管理になってしまう 3. container-query-polyfill を読み込む https://github.com/GoogleChromeLabs/container-query-polyfill 小中大の3サイズが確認できる。
- Loading branch information
1 parent
f2f9a03
commit f6284a1
Showing
2 changed files
with
46 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* Smaller version (ie. sidebar in this demo) */ | ||
@container (max-width: 200px) { | ||
.product-container { | ||
border: 1px solid #c2ceb0; | ||
padding: 0.5rem; | ||
border-radius: 10px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.product-container h3 { | ||
letter-spacing: 0; | ||
width: 90px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: pre; | ||
margin: 0; | ||
} | ||
|
||
.product-container span { | ||
margin: 0; | ||
} | ||
|
||
.product-container p, | ||
.product-container button { | ||
display: none; | ||
} | ||
} | ||
|
||
/* wider sizes (i.e in hero) */ | ||
@container (min-width: 350px) { | ||
.product-container { | ||
padding: 0.5rem 0 0; | ||
display: flex; | ||
} | ||
.product button { | ||
margin-left: 1rem; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters