6
4

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 5 years have passed since last update.

遠近感のない立方体を CSS でつくる

Last updated at Posted at 2018-05-19

つくるもの

スクリーンショット 2018-05-19 18.51.02.png

方法

  • 長方形の右側と下側にひし形をくっつけているだけです。
  • ひし形は transform:skewY(45deg) などを使うと簡単にできます。

他に良い方法はないものでしょうか.. :no_mouth:

コード

<div class="cube">
  りったいてきなものをつくりたい
  <div class="right-side"></div>
  <div class="bottom-side"></div>
<div>
.cube {
  padding: 20px;
  box-sizing: border-box;
  border-left: solid 3px black;
  border-top: solid 3px black;
  background-color: #fff;
  width: 300px;
  height: 200px;
  position: relative;
}
.right-side {
  box-sizing: border-box;
  position: absolute;
  top: -3px;
  right: -30px;
  border: solid 3px black;
  border-top: solid 4px black;
  border-bottom: solid 2px black;
  background-color: #f9f3d3;
  height: 200px;
  width: 30px;
  transform-origin:0 0;
  transform:skewY(45deg);
}
.bottom-side {
  box-sizing: border-box;
  position: absolute;
  bottom: -30px;
  left: -3px;
  border: solid 3px black;
  border-left: solid 4px black;
  border-right: solid 2px black;
  background-color: #f9f3d3;
  height: 30px;
  width: 300px;
  transform-origin:0 0;
  transform:skewX(45deg);
}

以上です。

6
4
1

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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?