Snake
How do I make an snake?
Earlier today I saw a discussion on twitter about this topic. :P "If a snake was responsive how would it be?". What is a snake? How do you make a snake? This script and codes were developed by Angela Velasquez on 10 December 2022, Saturday.
Snake - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Snake</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container"> <h2>This snake is...</h2> <form> <p class="form__answer"> <input type="radio" name="type" id="responsive" value="responsive" checked="checked"/> <label for="responsive">Responsive</label> </p> <p>or</p> <p class="form__answer"> <input type="radio" name="type" id="adaptive" value="adaptive"/> <label for="adaptive">Adaptive</label> </p> </form> <ul class="snake"> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> <p>Psst! Resize your browser window to see the result. </p>
</div>
<footer> <h2 class="footer__title">About this pen</h2> <h3 class="footer__subtitle">Snake</h3> <p class="footer__parragraph">Earlier today I saw a discussion on twitter about this topic. :P "If a snake was responsive how would it be?"</p> <p class="footer__parragraph">So I decided that it was good idea to make a pen about it.</p> <p class="copyright">Awesome pen by<a target="_blank" href="https://codepen.io/AngelaVelasquez">Angela</a></p>
</footer></footer> <script src="js/index.js"></script>
</body>
</html>
Snake - Script Codes CSS Codes
/* Imported Font from google fonts */
@import url("https://fonts.googleapis.com/css?family=Fira+Sans:400,600");
/* Color palette */
body, html { font-family: 'Fira Sans', sans-serif; background-color: #FAFAFA;
}
h2 { color: #3BA99C; font-size: 35px;
}
p { color: #C3C5C5;
}
form { display: -webkit-box; display: -ms-flexbox; display: flex; margin: 20px auto 40px; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
}
form p { margin: 0 10px; font-size: 22px;
}
.form__answer input { visibility: hidden; width: 0;
}
.form__answer label { cursor: pointer; display: inline-block; position: relative;
}
.form__answer label:hover { color: rgba(59, 169, 156, 0.5);
}
.form__answer label:after { display: block; content: ''; position: absolute; margin: auto; height: 8px; width: 8px; background-color: transparent; border-radius: 4px; left: 0; right: 0; -webkit-transition: background .4s ease-in-out; transition: background .4s ease-in-out;
}
input[type="radio"]:checked ~ label { color: #3BA99C;
}
input[type="radio"]:checked ~ label:after { background-color: #3BA99C;
}
.container { width: 80%; margin: 20vh auto; text-align: center;
}
/* Snake styles */
.snake { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between; max-width: 960px; margin: 0 auto; padding: 20px 0; list-style: none;
}
li { display: -webkit-inline-box; display: -ms-inline-flexbox; display: inline-flex; width: auto; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; height: 20px; position: relative;
}
li:before, li:nth-child(5):after { display: block; position: absolute; content: ''; background: #85FFD5; width: 100%; height: 20px; bottom: 0; border-bottom: 4px solid #3BA99C;
}
li:first-child:before, li:first-child:nth-child(5):after { border-radius: 20px 0 0 20px;
}
li:nth-child(5):before, li:nth-child(5):after { border-radius: 0 20px 20px 0;
}
li:nth-child(5):after { background: #3BA99C; height: 6px; width: 10px; border-radius: 10px; right: 20px; bottom: 8px; border-color: transparent;
}
/* Snake styles for adaptivee behavior*/
@media only screen and (max-width: 667px) { .snake.adaptive { -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; } .snake.adaptive li:first-child:before, .snake.adaptive li:first-child:nth-child(5):after { border-radius: 20px 20px 0 20px; } .snake.adaptive li:nth-child(2):before, .snake.adaptive li:nth-child(2):nth-child(5):after, .snake.adaptive li:nth-child(4):before, .snake.adaptive li:nth-child(4):nth-child(5):after { height: 100%; width: 20px; bottom: 0; right: 0; } .snake.adaptive li:nth-child(3):before, .snake.adaptive li:nth-child(3):nth-child(5):after { border-radius: 20px 0 20px 0; } .snake.adaptive li:nth-child(4):before, .snake.adaptive li:nth-child(4):nth-child(5):after { right: auto; left: 0; } .snake.adaptive li:nth-child(5):before, .snake.adaptive li:nth-child(5):after { border-radius: 0 20px 20px 20px; } .snake.adaptive li:nth-child(5):after { border-radius: 10px; }
}
/* Footer Styles */
footer { background-color: #3BA99C; position: relative; padding: 20px;
}
footer h2, footer h3, footer p, footer ul { max-width: 610px; margin: 20px auto;
}
.footer__title { font-size: 30px; margin-top: 40px; color: rgba(250, 250, 250, 0.5);
}
.footer__subtitle { font-size: 22px; color: #FAFAFA;
}
.footer__parragraph, .footer__list, .copyright { line-height: 1.5em; font-size: 22px; color: #FAFAFA;
}
.footer__parragraph a, .footer__list a, .copyright a { color: #85FFD5; padding: 6px;
}
.copyright { text-align: center; border-top: 1px dashed rgba(250, 250, 250, 0.45); padding: 10px 0; margin: 40px auto;
}
Snake - Script Codes JS Codes
//Crappy Jquery begins here
$("#responsive").click( function(){ if( $(this).is(':checked') ) { $(".snake").addClass("responsive"); $(".snake").removeClass("adaptive"); }
});
$("#adaptive").click( function(){ if( $(this).is(':checked') ) { $(".snake").addClass("adaptive"); $(".snake").removeClass("responsive"); }
});
//It is my first time using JS. If you have any recommendation I would really appreciate it. Feel free to comment!
Developer | Angela Velasquez |
Username | AngelaVelasquez |
Uploaded | December 10, 2022 |
Rating | 4.5 |
Size | 5,200 Kb |
Views | 20,240 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
CSS Switch Day and Night - Cat | 2,824 Kb |
Pure css vertical menu | 2,310 Kb |
CSS on hover effects | 2,689 Kb |
CSS Switch Day and Night - Fox | 2,862 Kb |
CSS - Cat in the sky | 2,610 Kb |
CSS - Cat on ride | 2,999 Kb |
CSS - Cat on a Plane | 2,774 Kb |
CSS - Cat with balloon | 2,849 Kb |
CSS - Cat on the Moon | 2,564 Kb |
My Valentine | 3,353 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
React Markdown Previewer | C0d0er | 3,190 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
Material design - button rainbow circle | Kunukn | 3,652 Kb |
Z-index demo | Kblh | 1,534 Kb |
Touch Carousel - last, no gaps. | Berkin | 4,332 Kb |
Spin | Elalemanyo | 8,262 Kb |
CSS Google Now | Jackmoran | 3,196 Kb |
Learning FlexBox | Alex_rodrigues | 2,821 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Minimal Menu | Achudars | 3,430 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!