Skip to content

Instantly share code, notes, and snippets.

@evaldas-raisutis
Last active November 22, 2017 18:14
Show Gist options
  • Save evaldas-raisutis/10544712 to your computer and use it in GitHub Desktop.
Save evaldas-raisutis/10544712 to your computer and use it in GitHub Desktop.
Responsive html calendar with javascript
#calendar {
margin-top:5em;
width: 100%;
}
#month {
text-align:center;
text-transform:uppercase;
}
.day {
display:inline;
width:13.285%;
height: 13.285%;
padding: 3% 0.5%;
float:left;
text-align:center;
font-size:1.2em
}
.day:hover {
background-color: lightgray;
}
.hasEvent {
background-color:blue;
}
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="calendar">
<div id="month"></div>
<div id="days"></div>
</div>
</body>
</html>
var month = {
"title": "january",
"days": 31
};
$("#month").text(month.title);
for(var x = 1; x <= month.days; x++) {
$("<div>" + x + "</div>")
.addClass("day")
.addClass("day-" + x)
.appendTo("#days");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment