Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
30
Help us understand the problem. What is going on with this article?
@junya

CSS 歪みを使ったデザイン

More than 5 years have passed since last update.

transformのskewX , skewY を使えば要素を歪められる

引数は角度
transform: skewX(30deg);

歪みを使ったデザインを3つ用意しました。

その1 skewX

sample001.png


<div class="box1">
<h1 class="text">Hello World!</h1>
</div>


.box1{
  display: inline-block;
  margin-left: 1em;
  padding: 0 1em;
  background-color: blue;
  transform: skewX(30deg);
}

.box1 .text{
  margin: 0;
  padding: 0;
  color: white;

  /* 親の要素の回転と逆回転で指定 */
  transform: skewX(-30deg);
}


その2 skewX と 角丸

sample002.png


<div class="box2">
<h1 class="text">Howdy!</h1>
</div>


.box2{
  display: inline-block;
  margin-left: 1em;
  padding: 0 1em;

  /* 角丸 */
  border-radius: 5px;
  background-color: green;
  transform: skewX(-30deg);
}

.box2 .text{
  margin: 0;
  padding: 0;
  color: white;

  /* 親の要素の回転と逆回転で指定 */
  transform: skewX(30deg);
}

その3 skewY と 縦書き

sample003.png


<div class="box3">
<h1 class="text">こんにちは、世界。</h1>
</div>


.box3{
  display: inline-block;
  width: 3em;
  margin-top: 1em;
  margin-left: 1em;
  padding: 1em 0;
  background-color: red;
  transform: skewY(30deg);
}

.box3 .text{
  margin: 0;
  padding: 0;
  color: white;

  /* 親の要素の回転と逆回転で指定 */
  transform: skewY(-30deg);

  /* 縦書き */
  -webkit-writing-mode: vertical-rl;
  -ms-writing-mode: vertical-rl;
  writing-mode: vertical-rl;
}

30
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
junya

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
30
Help us understand the problem. What is going on with this article?