Skip to content

Instantly share code, notes, and snippets.

@alexmwalker
Created March 12, 2012 09:53
Show Gist options
  • Select an option

  • Save alexmwalker/2020969 to your computer and use it in GitHub Desktop.

Select an option

Save alexmwalker/2020969 to your computer and use it in GitHub Desktop.
CSS3 Pong *
/**
* CSS3 Pong *
*/
@import url(http://fonts.googleapis.com/css?family=VT323);
body{
background: #000;
color:#070;
font-family:'VT323', Courier, "Courier New", monospace;
text-align:center
}
a:link {color:#f0f;
text-decoration:none;
}
a:hover {color:#f9f;
text-decoration:none;
}
a:visited {color:#ff0;
text-decoration:none;
}
#court {
margin-top:40px;
border:5px dotted #0a0;
border-width:5px 0;
height:500px;
position:relative;
overflow:hidden;
}
#court::before {
content: "";
height:100%;
display:block;
top:0;
width:5px;
left:48%;
position:absolute;
background:#0a0
}
#court::after {
content: "0 0";
text-align:center;
font-size:100px;
height:100%;
color:#070;
display:block;
top:0;
width:40%;
left:28%;
position:absolute;
}
h1, h2, p{
text-shadow:0 0 5px #050
}
p{
font-size:24px;
}
#horizontal {
width: auto;
height:20px;
padding-left:5px;
padding-right:20px;
position:relative;
outline:1px dashed red;
/animation: vertical 2.3s infinite linear;
}
#ball { /* the ball */
background:#ce0;
width: 20px;
height:20px;
border-radius:20px;
box-shadow:0 0 10px #0f0;
outline:1px dashed red
}
#vertical{
animation: horizontal 10s infinite linear;
}
#bat1, #bat2 {
background:#f00;
width: 10px;
height:60px;
margin-top:-10px;
position:absolute;
right:0px;
top:0px;
color:red;
animation: twitchy1 1.9s infinite linear;
}
#bat2 {
left:0;
animation: twitchy2 1.9s infinite linear;
background:#ff0
}
@keyframes vertical { /* vertical movement */
0%,100% {
top:0%;
margin-top:0px
}
50% {
top:100%;
margin-top:-20px
}
}
@keyframes horizontal { /* horizontal movement */
0%, 100 {
transform: translateX(100px);
}
50% {
transform: translateX(200px);
}
}
<!-- content to be placed inside <body>…</body> -->
<div id="court">
<div id="horizontal">
<div id="targetzone">
<div id="ball"></div>
</div>
</div>
</div>
<h2>CSS3 Epic Pong</h2>
Insert coin to begin
{"view":"split-vertical","seethrough":"","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment