I've got troubles making a styling for an array,
Here is my code:
This is my HTML:
<!DOCTYPE HTML>
<html>
<head>
<title>test</title>
<script src="card.js"></script>
<script src="Deck.js"></script>
<link rel="stylesheet" href="card.css">
</head>
<body onload = "addCard()">
</body>
</html>
Here is my first JavaScript file with the array (Deck) which refers to my second JavaScript file with the card:
var Deck = new Array();
function addCard(){
Deck[0] = new Card("test");
Deck[1] = new Card("1234");
}
Here is my second JavaScript file with the card:
class Card{
constructor(myText){
document.write("<div class = \"card\">");
document.write("<div class = \"back\">");
document.write("<div class = \"up\"><\/div>");
document.write("<div class=\"down\"><\/div>");
document.write("<hr class = \"arrowUpLeft\">");
document.write("<hr class = \"arrowDownRight\">");
document.write("<hr class = \"arrowUpRight\">");
document.write("<hr class = \"arrowDownLeft\">");
document.write("<div class = \"front\">");
document.write("<p id =\"text_card\">");
document.write(myText);
document.write("<\/p>");
document.write("<\/div>");
document.write("<\/div>");
document.write("<\/div>");
}
}
And this is my CSS:
.card{
height: 336px;
width: 240px;
border: 4px solid transparent;
border-radius: 50px;
box-sizing: border-box;
z-index: 2;
position: relative;
bottom: 100%;
}
.card:hover > .back{
animation: cardturn 1s;
background-color: blue;
}
.card:hover>.back :not(.front), .card:hover>.back :not(.front)>*{
animation: cardturn 1s;
animation: setvisibilityBackInvisible 1s;
visibility: hidden;
}
.card:hover>.back>.front, .card:hover>.back>.front>*{
animation: setvisibilityBackVisible 1s;
visibility: visible;
}
.back{
height: 328px;
width: 232px;
background-color: red;
border-radius:46px;
z-index: 2;
border: 4px solid black;
animation: cardturn2 1s;
}
.front, .front>*{
animation: setvisibilityBackInvisible 1s;
visibility: hidden;
}
.back>:not(.front), .back>:not(.front)>*{
animation: setvisibilityBackVisible 1s;
visibility: visible;
}
.up{
position: relative;
top: 114px;
left: 66px;
height: 0px;
width: 0px;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 50px solid blue;
background-color: transparent;
}
.down{
position: relative;
top: 114px;
left: 66px;
height: 0px;
width: 0px;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 50px solid blue;
background-color: transparent;
}
.arrowUpLeft{
position: relative;
top: -22px;
left:-25px;
width: 214px;
transform: rotate(45deg);
border: 2px solid black;
}
.arrowDownRight{
position: relative;
top: 118px;
left:25px;
width: 214px;
transform: rotate(45deg);
border: 2px solid black;
}
.arrowUpRight{
position: relative;
top: 4px;
left:-25px;
width: 70px;
transform: rotate(-45deg);
border: 2px solid black;
}
.arrowDownLeft{
position: relative;
top: 44px;
left:25px;
width: 70px;
transform: rotate(-45deg);
border: 2px solid black;
}
@keyframes cardturn{
0%,100%{
transform: scale(1,1);
}
50%{
transform: scale(0,1);
background-color: red;
}
51%{
background-color: blue;
}
0%{
background-color: red;
}
100%{
background-color:blue;
}
}
@keyframes cardturn2{
0%,100%{
transform: scale(1,1);
}
50%{
transform: scale(0,1);
background-color: blue;
}
51%{
background-color: red;
}
100%{
background-color: red;
}
0%{
background-color: blue;
}
}
@keyframes cardturn3{
0%,100%{
transform: scale(1,1);
}
50%{
transform: scale(0,1);
}
}
@keyframes setvisibilityBackInvisible{
0%,50%{
visibility: visible;
}
51%,100%{
visibility: hidden;
}
}
@keyframes setvisibilityBackVisible{
0%,50%{
visibility: hidden;
}
100%{
visibility: visible;
}
}
I hope you can help me guys, I would thank you very much. Even if you could just only explain why the CSS doesn't work could explain I actually would be very happy, because I then know what to do.