我不斷收到這段代碼的錯誤。具體而言,它是一個未捕獲的typeerror,它說,一個id爲null,即使它不是。找不到null的innerHTML,css3轉換翻轉
<!DOCTYPE HTML>
<html>
<head>
<title>Flip the card over </title>
<link rel="stylesheet" type="text/css" href="cardFlipper.css">
<script>
var front = new Array("ante","anti","bi","circum","com","con","de","dis","equi","extra","inter","intra")
var back = new Array("before","against","bi","around","together","together","down","away","equal","beyond","between","within")
var placeholder = eval(0);
var cardFront = document.getElementById("cFront").innerHTML
var cardBack = document.getElementById("cBack").innerHTML
function rightCard()
{
placeholder += 1
cardFront = front[placeholder]
cardBack = back[placeholder]
}
function leftCard()
{
placeholder -= 1
cardFront = front[placeholder]
cardBack = back[placeholder]
}
function flipCard(theCard)
{
if(theCard.className == 'front')
theCard.className='flipped';
else
theCard.className='front';
}
</script>
</head>
<body>
<div id=deck class="container">
<div id="card" onClick="flipCard(this)">
<figure class="front" id="cFront">ante</figure>
<figure class="back" id="cBack">before</figure>
</div>
</div>
<input type=button id=left value="<-----" onclick="leftCard()">
<p class=tab></p>
<input type=button id=right value="----->" onclick="rightCard()">
</body>
</html>
這就是CSS。我正在嘗試將圖中的文本更改爲可行的內容。
.tab { margin-left: 40px;
}
.container{
width: 200px;
height: 260px;
position: relative;
perspective: 800px;
-webkit-perspective: 800px;
margin: 0 auto 40px;
border: 1px solid #CCC;
}
#card {
width: 100%;
height: 100%;
position: absolute;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
transition: transform 1s;
-webkit-transition: -webkit-transform 1s;
}
#card figure {
display: block;
position: absolute;
width: 100%;
height:100%;
color: white;
font-size: 40px;
margin: 0;
text-align: center;
line-height: 260px;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
#card .front{
background: red;
}
#card .back {
background: blue;
-webkit-transform: rotateY(180deg);
}
#card.flipped {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
哪條線導致錯誤? – 2014-12-19 01:40:50