課程
/前端開發(fā)
/CSS3
/CSS3 3D 特效
怎么用純css3實現(xiàn)
2016-11-12
源自:CSS3 3D 特效 3-2
正在回答
var curIndex = 1 ;
function prev() {
if(curIndex == 1) return;
var curPage = document.getElementById("page" + curIndex);
curPage.style.webkitTransform = "rotateX(90deg)";
curIndex--;
var prevPage = document.getElementById("page" + curIndex);
prevPage.style.webkitTransform = "rotateX(0deg)";
}
function next() {
if(curIndex == 6) return;
curPage.style.webkitTransform = "rotateX(-90deg)";
curIndex++;
var nextPage = document.getElementById("page" + curIndex);
nextPage.style.webkitTransform = "rotateX(0deg)";
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>3D正方體</title>
<style type="text/css">
.main {
margin: 100px auto;
width: 100px;
height: 100px;
position: relative;
/*3D設(shè)置*/
perspective: 600px;
perspective-origin: 50% 50%;
transition: all 1s;
transform-origin: center;
transform-style: preserve-3d;
section {
transition: all 3s;
.item {
position: absolute;
color: white;
background-color: rgba(0,0,0,1);
font-size: 30px;
font-weight: bold;
text-align: center;
line-height: 100px;
z-index: 10;
.item:nth-child(1) {
.item:nth-child(2) {
transform-origin: right;
transform: rotateY(90deg);
.item:nth-child(3) {
transform-origin: left;
transform: rotateY(-90deg);
.item:nth-child(4) {
transform-origin: bottom;
transform: rotateX(-90deg);
.item:nth-child(5) {
transform-origin: top;
transform: rotateX(90deg);
.item:nth-child(6) {
z-index: 100;
transform: translateZ(100px);
section:hover {
/*transform:rotate3d(0,1,1,45deg);*/
transform: rotateY(280deg);
</style>
</head>
<body>
<div class="main">
<section>
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</section>
</div>
</body>
</html>
銘天更精彩 提問者
舉報
使用CSS3當中的屬性,創(chuàng)建真實可用的三維效果
1 回答有人能給我一段3d效果的代碼嗎?
2 回答css 3d效果ie也能實現(xiàn)嗎
2 回答前綴用-moz在火狐無法實現(xiàn),但-webkit在google能實現(xiàn)3d
1 回答不知道這樣寫合不合規(guī)矩,可是效果能實現(xiàn),請問有沒有問題
2 回答為什么我的代碼沒任何效果,能翻頁但沒有3D效果
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-12-14
var curIndex = 1 ;
function prev() {
if(curIndex == 1) return;
var curPage = document.getElementById("page" + curIndex);
curPage.style.webkitTransform = "rotateX(90deg)";
curIndex--;
var prevPage = document.getElementById("page" + curIndex);
prevPage.style.webkitTransform = "rotateX(0deg)";
}
function next() {
if(curIndex == 6) return;
var curPage = document.getElementById("page" + curIndex);
curPage.style.webkitTransform = "rotateX(-90deg)";
curIndex++;
var nextPage = document.getElementById("page" + curIndex);
nextPage.style.webkitTransform = "rotateX(0deg)";
}
2016-11-15
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>3D正方體</title>
<style type="text/css">
.main {
margin: 100px auto;
width: 100px;
height: 100px;
position: relative;
/*3D設(shè)置*/
perspective: 600px;
perspective-origin: 50% 50%;
transition: all 1s;
transform-origin: center;
transform-style: preserve-3d;
}
section {
width: 100px;
height: 100px;
transition: all 3s;
transform-style: preserve-3d;
}
.item {
position: absolute;
width: 100px;
height: 100px;
color: white;
background-color: rgba(0,0,0,1);
font-size: 30px;
font-weight: bold;
text-align: center;
line-height: 100px;
z-index: 10;
}
.item:nth-child(1) {
}
.item:nth-child(2) {
transform-origin: right;
transform: rotateY(90deg);
}
.item:nth-child(3) {
transform-origin: left;
transform: rotateY(-90deg);
}
.item:nth-child(4) {
transform-origin: bottom;
transform: rotateX(-90deg);
}
.item:nth-child(5) {
transform-origin: top;
transform: rotateX(90deg);
}
.item:nth-child(6) {
z-index: 100;
transform: translateZ(100px);
}
section:hover {
transform-origin: left;
/*transform:rotate3d(0,1,1,45deg);*/
transform: rotateY(280deg);
}
</style>
</head>
<body>
<div class="main">
<section>
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</section>
</div>
</body>
</html>