0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CSSで使えそうで使ったことない機能メモ

Last updated at Posted at 2022-11-12

関数

min()

div{
    width: 50%;
    max-width: 800px;
}

これは↓のように書ける

div{
    width: min(50%, 800px)
}
  • 親要素の80%ただし800pxでクリップする

max()

div{
    width: 50%;
    min-width: 300px;
}

これは↓のようにも書ける

div{
    width: max(50%, 300px)
}
  • 親要素の50% ただし300pxを下回らない

clamp()

div{
    width: 50%;
    min-width: 150px;
    max-width: 800px;
}

これは↓のよにも書ける

div{
    width: clamp(150px, 50%, 800px);
}
  • 見出しなどのテキストをvwで指定して画面幅に応じて変えたいときなど
div{
    font-size: clamp(18px, 2.8vw, 36px);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?