Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div id="endAPP">
<h1>Paper, scissors or rock <small>(<i>one more version</i>)</small></h1>
<div class="corse"><div><span id="countComputer">0</span> Computer</div><div>You <span id="countHuman">0</span></div></div>
<div id="container" ><div>
<span id="computer"><div class="arm" play="rock"></div></span>          
</div><div class="right">
<span id="human"><div class="arm"  play="rock"></div></span>
</div></div>
<div class="corse"><input id="paper" type="button" value="paper"><label for="paper"><span>✋</span></label><input id="scissors" type="button" value="scissors"><label for="scissors"><span>✌️</span></label><input id="rock" type="button" value="rock"><label for="rock"><span>✊</span></label></div>
</div>  
<div class="title">Do you have intuition?</div>
<p>Our ancestors relied on intuition to achieve their purposes.</p> 
<p>We currently forget it and only trust if there is an arrow pointing to the EXACT point. :S</p>
<div class="title">Intuition experiment</div>
<p>The <b>computer</b> has the <b>decision</b> made <b>before</b> you make the play, so you can win it using <b>your intuition</b>.</p>
<p>Make series of plays and write a comment about the results, thanks</p>
<br><br><br>
<author style="margin:10px;display:block"> 
<img style="width: 40px; border-radius: 50%;vertical-align: middle; background-color:black;transform:scale(-1,1)" src="https://s.cdpn.io/profiles/user/3103547/512.jpg?1555236072" alt="Avatar of Jomohop"> by 
<a href="https://codepen.io/jomohop"  target="_blank" style="color:black; font-size: 18px;vertical-align: middle"> Jomohop</a> 
</author>
              
            
!

CSS

              
                *{
margin:0;
}
html,body{
height: 100%;
}
body{
background-image: linear-gradient(75deg,white,  lightgray 5%,white 15%, lightgray 55% , lightgray 90%,white);
background-size: 100%;
background-attachment: fixed;
min-height: 300px;
font-family: arial,sans-serif;
overflow-x: hidden;
}
#endAPP{
min-height:90% 
} 
h1{
margin:0;
font-weight: normal;
font-size: 32px;
line-height:24px;
margin-bottom: 50px;   
}
.corse{
width: 600px;
max-width: 100%;
margin:auto;
}
.corse>div{
display:inline-block;
text-align: center;
width: 50%;
font-size: 24px;
}
.corse>div>span{
display:inline-block;
width:60px;
background-color: black;
color:white;
line-height: 60px;
text-align: center;
border-radius: 50%;
transition:.2s;
box-shadow: "0 0 0 0 transparent";
border:1px solid white;
}
#container{
width: 600px;
margin-left:calc(50% - 300px);
margin-bottom: 100px;
position: relative;
z-index: 1;
}  
#container>div{
display:inline-block;
width: 50%;
padding: 20px 0;
}
.arm{
border:10px solid black;
width: 200px;
height: 60px;
background-color: #ffc83d;
border-radius: 20px;
text-align:left;
display: inline-block;
transition:.3s;
}
.right{
text-align:right;
}
.arm[play=paper]::before{
content: '✋';
position:absolute;
font-size: 150px;
line-height: 0;
transform:translate(-100px,10px) rotate(-90deg); 
}
.arm[play=scissors]::before{
content: '✌️';
position:absolute;
font-size: 150px;
line-height: 0;
transform:translate(-80px,30px) rotate(-90deg); 
}
.arm[play=rock]::before{
content: '✊';
position:absolute;
font-size: 150px;
line-height: 0;
transform:translate(-90px,30px) rotate(-90deg); 
}
#computer>div{
transform:scaleX(-1);
}
#human,#computer{
display:inline-block;
vertical-align: middle;     
animation-name: prePlay;
animation-iteration-count:infinite;
animation-direction:alternate ;
animation-timing-function: ease-in-out;
transition:.2s;
}
#human{
transform-origin: right center;
}
#computer{
animation-direction: alternate-reverse;
transform-origin:center left ;
}  
input[type=button]{
display: none;
}
input[type=button]:disabled+label{
cursor:none;
}
.corse>label{
width: 33.3333%;
display:inline-block;
vertical-align: top;
text-align: center;
box-sizing: border-box;
border:1px dashed white;
font-size: 40px;
cursor:pointer;
transition:.3s;
}
.corse>label>span{
transform: rotate(-90deg);
display:inline-block;
}
.corse>label:hover{
border-color:gray;
}
@keyframes prePlay {
from {transform: rotate(-4deg);}
to {transform: rotate(8deg);}
}
.title{
font-size: 24px;
}
              
            
!

JS

              
                var countComputer = 0
var spanCountComputer = document.getElementById("countComputer")
var spanCountHuman = document.getElementById("countHuman")
var countHuman = 0
var computer = document.getElementById("computer") 
var human = document.querySelector("#human")
document.querySelectorAll(".corse>input").forEach(function(input){
    input.onclick = function(){
      result(this.value)       
      document.querySelector("[for="+this.id+"]").style.boxShadow = "inset 0 0 0 30px black"
    }
})
function showResult(winner){      
    switch(winner){
        case "human":
            human.style.opacity = 1
            countHuman++
            spanCountHuman.innerHTML = countHuman
            spanCountHuman.style.backgroundColor = "green"
            spanCountHuman.style.boxShadow = "0 0 10px 10px green"
            spanCountHuman.style.transform = "scale(1.1)"
        break
        case "computer":
            computer.style.opacity = 1                
            countComputer++
            spanCountComputer.innerHTML = countComputer
            spanCountComputer.style.backgroundColor = "green"
            spanCountComputer.style.boxShadow = "0 0 10px 10px green"
            spanCountComputer.style.transform = "scale(1.1)"
        break            
        default:
            human.style.opacity = 1
            computer.style.opacity = 1
            spanCountComputer.style.backgroundColor = "gray"
            spanCountHuman.style.backgroundColor = "gray"
            spanCountComputer.style.transform = "scale(.9)"
            spanCountHuman.style.transform = "scale(.9)"
        break       
    }
    document.querySelectorAll("input[type=button]").forEach(function(input){
        input.disabled = true
    })
    computer.style.transition = ".3s"
    human.style.transition = ".3s"
    setTimeout(function(){            
        computer.style.transform = "rotate(8deg)"
        human.style.transform = "rotate(-4deg)"
        setTimeout(function(){
            computer.style.opacity = 1
            computer.style.animationName = "prePlay"                
            animationDuration(computer)    
            computer.firstChild.setAttribute("play","rock")
            spanCountComputer.style.backgroundColor = ""
            spanCountComputer.style.boxShadow = ""
            spanCountHuman.style.backgroundColor = ""
            spanCountHuman.style.boxShadow = ""
            human.style.opacity = 1
            human.style.animationName = "prePlay"
            animationDuration(human)
            human.firstChild.setAttribute("play","rock")
            spanCountHuman.style.transform = ""
            spanCountComputer.style.transform = ""
            document.querySelectorAll(".corse>label").forEach(function(label){
                label.style.boxShadow = ""
            })
        },250)
        document.querySelectorAll("input[type=button]").forEach(function(input){
        input.disabled = false
        })
        computerDecision()
    },1000)
}
function computerDecision(){
    var option=["paper","scissors","rock"]
    choiceComputer = option[Math.floor(Math.random()*3)]
    console.clear()
    console.log("computer decision:",choiceComputer)
}
function result(choice){              
    computer.style.animationName = "none"        
    computer.style.transition = "0s"
    computer.style.transform = "rotate(0)"        
    human.style.animationName = "none"        
    human.style.transition = "0s"
    human.style.transform = "rotate(0)"
    setTimeout(function(){
       computer.style.transition = ".2s ease-out"
       computer.style.transform = "rotate(30deg)"
       computer.firstChild.setAttribute("play",choiceComputer)            
       human.style.transition = ".2s ease-out"
       human.style.transform = "rotate(-30deg)"
       human.firstChild.setAttribute("play",choice)  
       showResult(winner)
    },20)
    var winner="computer"
    if (choiceComputer == choice) winner = "tie"
    if (choiceComputer == "paper" && choice == "scissors") winner="human"
    if (choiceComputer == "scissors" && choice == "rock") winner="human"
    if (choiceComputer == "rock" && choice == "paper") winner="human"
}
function animationDuration(object){
    var duration= (4 + Math.random() ).toFixed(1)
    object.style.animationDuration = duration / 10 + "s"
}
document.querySelectorAll("#human,#computer").forEach(function(object){
    animationDuration(object)
})
computerDecision()
              
            
!
999px

Console