結果のプレビュー
押してフルスクリーンプレビューへのリンクをクリックして、現在のページをプレビューする権利「プレビュー]をクリックします」ボタンをクリックします。
https://codepen.io/comehope/pen/xagoYb
インタラクティブビデオ
このビデオでは、対話型である、あなたがビデオを編集して、コードのビデオを一時停止することができます。
クロム、サファリ、エッジオープンビューを使用してください。
https://scrimba.com/p/pEgDAM/cPw8eSg
ソースコードのダウンロード
毎日のフロントエンド戦闘シリーズ完全なソースコードはgithubのからダウンロードできます。
https://github.com/comehope/front-end-daily-challenges
コード読み取り
DOMを定義すると、容器は頭、首、体の側面、翼、尾、胸を代表する、6つの要素が含まれています。
<div class="cranes">
<span class="head"></span>
<span class="neck"></span>
<span class="side"></span>
<span class="wing"></span>
<span class="tail"></span>
<span class="belly"></span>
</div>
中央揃え:
body {
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: dodgerblue;
}
定義されたコンテナのサイズであります:
.cranes {
width: 52em;
height: 50em;
font-size: 7px;
}
白い折り鶴に色を設定します。
.cranes {
color: white;
}
頭を描きます:
.cranes {
position: relative;
}
.head {
border-left: 13em solid transparent;
border-right: 6em solid transparent;
border-bottom: 2em solid;
position: absolute;
left: 0;
top: 21;
transform: rotate(-5deg);
}
上記のコードは、テンプレートに抽象三角形を作成し、その後、データのような関数を呼び出すと、変数と同様に変更されます。
.cranes span {
border-left: calc(var(--left) * 1em) solid transparent;
border-right: calc(var(--right) * 1em) solid transparent;
border-bottom: calc(var(--bottom) * 1em) solid;
position: absolute;
transform: rotate(calc(var(--rotation) * 1deg));
left: calc(var(--x) * 1em);
top: calc(var(--y) * 1em);
}
.head {
--left: 13;
--right: 6;
--bottom: 2;
--x: 0;
--y: 21;
--rotation: -5;
}
透明性に重畳している効果折り畳み要素に提供されます。
.cranes span {
filter: opacity(0.6);
}
次のステップは、三角形の三角形を生成するために、追加機能を作成するために、一つ一つを呼び出すことです。
ネック:
.neck {
--left: 6;
--right: 6;
--bottom: 12;
--x: 14;
--y: 19;
--rotation: 75;
}
ボディ側:
.side {
--left: 1.5;
--right: 11.5;
--bottom: 20;
--x: 18.8;
--y: 15.1;
--rotation: 20;
}
フィン:
.wing {
--left: 18.7;
--right: 30;
--bottom: 8;
--x: 6.7;
--y: 9.2;
--rotation: -41.9;
}
テール:
.tail {
--left: 18.6;
--right: 7.7;
--bottom: 3.9;
--x: 19.6;
--y: 38.1;
--rotation: -126.5;
}
胸:
.belly {
--left: 6.2;
--right: 1.8;
--bottom: 11.5;
--x: 17.5;
--y: 27.8;
--rotation: -99;
}
これまでのところ、未完成の折り鶴。
二等辺直角三角形によるマウスホバーは、クレーンを変形したときに最後に、少し相互作用効果を追加します。
.cranes:hover span {
animation: appear 1s ease-in;
}
@keyframes appear {
from {
border-left: 3em solid transparent;
border-right: 3em solid transparent;
border-bottom: 3em solid;
position: absolute;
transform: rotate(0deg);
left: calc((52em - 3em) / 2);
top: calc((50em - 3em) / 2);
}
}
私たちは完了です。