大風(fēng)車和色子的web前端代碼分享

大風(fēng)車

01大風(fēng)車
*{ margin:0;  padding:0;  } 
#box{
width:300px; height:300px;
margin:100px auto;
position:relative;
border-risze:50%
background-color:pink;
animation: moveCircle 1s linear infinite  paused;  動(dòng)畫}
@keyframes moveCircle{ form{ transform:rotate(0 deg);} to{ transform:rotate( 360 deg);}}
#box div { width:150px; height: 50px;position:absolute; top:100px;
/*background-color: orange;*/
border-top-left-radius: 100%; transform-origin: bottom right; }
#box div:nth-of-type(1){
background-color: rad;
}
#box div:nth-of-type(2){
background-color: green;
transform:rotate(90deg)
}
#box div:nth-of-type(3){
background-color:deepskyblue;
transform: rotate(180deg);
}
#box div:nth-of-type(4){
background-color: yellow;
transform:rotate(270deg)
}
input {
width: 200px; height: 50px; display : block; margin : 50px auto ; font-size : 30px; background-color: orange;
}
</style>
</head>
<body>
<div id="box">
<div>1</div> <div>2</div> <div>3</div> <div>4</div>
</div>
<input type="button" value="開始">

寫js
id是可以直接操作的,但是最好還是獲取一下。

<script type="text/javascript">
var btn = document.querySelector("input");
var box = document.querySelector("#box");

btn.onclick = function () {
if (this.value == '開始'){
this.value = '結(jié)束';
box.style.animationPlayState = 'running';
}else{
this.value = '開始';
box.style.animationPlayState = 'paused';
}}
</script>
</body>
</html>

再把剛才的進(jìn)行打開 獲取元素這塊id獲取

其實(shí)速度這塊也可以調(diào)。
盒子模型

盒子模型.gif

要注意給透視點(diǎn) ,

*{ margin : 0; paddind : 0;}
#box{
width: 300px;  height: 300px;
margin:100px auto;
position:relative;
transform-style:preserve-3d;
支持3D效果

animation: moveRect 2s linear infinite paused;
}
@keyframes moveRect {
from{
transform: perspective(1200px) rotateX(0) rotateY(0);
} to {
transform: perspective(1200px) rotateX(360deg) rotateY(360deg)
}
}
#box div {
width: 300px; height: 300px; position: absolute; font-size: 50px; font-weight: bold;
text-align: center; line-height: 300px; background-color: orange;
}
#box div:nth-of-type(1){
background-color: red; 
transform: translateZ(150px);
}
#box div:nth-of-type(2){
background-color: deepskyblue;
transform: rotateX(90deg) translateZ(-150px);
}
#box div:nth-of-type(3){
background-color:deepskyblue;
transform: rotateX(90deg) translateZ(150px);
}
#box div:nth-of-type(4){
background-color: deeppink;
transform: rotateX(-90deg) translateZ(150px);
}
#box div:nth-of-type(5){
background-color: yellow;
transform: rotateY(90deg) translateZ(150px);
}
#box div:nth-of-type(6){
background-color:yellow;
transform: rotateY(-90deg) translateZ(150px);
}
input{
width: 200px; height: 50px; display: block;
margin: 50px auto; font-size: 30px;
background-color: orande;
}
</style> </head>
<body>
<div id="box">
<div>1<div> <div>2<div><div>3<div><div>4<div><div>5<div><div>6<div>
</div>
<input type="button" value="開始" />

先把動(dòng)畫注掉
需要作出一個(gè),六個(gè)面 只需要將空間拉開就可以了,分為三部分 前后面,左右面,上下面,3oo*300 往前推300 只推一半 150 3D平移

<script type="text/javascript">
var bth = document.querySelector("input");
var box = document.querySelector("#box");

bth.onclick = function () {
if (this.value == '開始'){
this.value = '結(jié)束';
box.style.animationPlayState = 'running';
}eles{
this.value = '開始';
box.style.animationPlayState = 'paused';
}
}
</script> </dody> </html>

透視點(diǎn)可以調(diào),度數(shù)是可以調(diào) 數(shù)度也是可以調(diào) 要是有規(guī)則就取一樣的值,當(dāng)然360 是最好。
另外推薦兩部電影
《異次元世界》、《終極面試》 不是恐怖片 對(duì)心理有關(guān)的電影!
時(shí)鐘

時(shí)鐘.gif
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,523評(píng)論 25 708
  • 一、目標(biāo)群體: 想學(xué)畫畫、不懂透視 及 以為自己懂透視的同學(xué)。 小測試,為了不浪費(fèi)讀者的時(shí)間,請(qǐng)大家根據(jù)此圖,腦補(bǔ)...
    跨浪閱讀 22,784評(píng)論 4 65
  • 今天看到我們的寫作群里正在聊婚姻的事,我沒忍住就把我的事情在群里說了。之前我一直不想說這個(gè)話題,因?yàn)橛X得有點(diǎn)難堪,...
    多愁善感的柳小姐閱讀 150評(píng)論 3 0
  • L君,我現(xiàn)在最開心的事情就是和你聊天了。 傍晚望向窗外的時(shí)候,看見橙色的陽光撲來。橙色是最讓我感到幸福的顏色,而且...
    仙魚卷閱讀 300評(píng)論 2 4
  • 一群少年在一位老人家門前嬉鬧玩耍,叫聲連天。幾天過去,老人難以忍受。 于是,她出來給了每個(gè)少年20文錢,對(duì)他們說:...
    張連州閱讀 631評(píng)論 0 0