
How to create a Flex Calendar in html
Before We Start
Every developer needs clean and modern elements to develop their websites, It contains pictures and a user interface element within a website. The most important one and the first section that the user sees when the user enters a website. How to create a Flex Calendar in html
So if you are a person who wishes to develop a website, you have to know how to create that properly.

How to create a Flex Calendar in html
We are here to solve your problem. In this article we discuss how to create these elements. Before we start please read the below articles which easier you to understand the process, if you are new to development.
Step 1 – Add HTML
It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag.
<div ng-app="app">
<div ng-controller="MainController">
<h1>
<span class="l">Flex</span><span class="r">Calendar</span>
</h1>
<p>An Elegant Calendar Built With Angular.js</p>
<div class="wrapp">
<flex-calendar options="options" events="events"></flex-calendar>
</div>
<br />
<p>
<iframe src="https://ghbtns.com/github-btn.html?user=Russian60&repo=flex-calendar&type=star&count=true&size=large" frameborder="0" scrolling="0" width="115px" height="30px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=Russian60&repo=flex-calendar&type=watch&count=true&size=large&v=2" frameborder="0" scrolling="0" width="130px" height="30px"></iframe>
</p>
</div>
</div>
Step 2 – Add CSS
Copy and paste below code in your HTML editor between <style></style> tag.
<style>
* {
-webkit-font-smoothing: antialiased;
}
body {
font-family: "helvetica neue";
background-color: #a25200;
margin: 0;
}
h1 {
color: #ffffff;
text-align: center;
margin-top: 30px;
margin-bottom: 0px;
font-size: 40px;
}
p {
margin-top: 5px;
margin-bottom: 25px;
color: #fff;
font-weight: 300;
}
span.l {
font-weight: 100;
}
span.r {
font-weight: 500;
}
.wrapp {
width: 450px;
height: 75%;
margin: 0 auto;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-content: center;
align-items: center;
}
p {
text-align: center;
}
flex-calendar {
}
/* Library */
.flex-calendar .days .day.selected,
.flex-calendar .month {
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
}
.flex-calendar .days,
.flex-calendar .days .day.selected,
.flex-calendar .month,
.flex-calendar .week {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
}
.flex-calendar {
width: 100%;
min-height: 50px;
color: #fff;
font-weight: 200;
}
.flex-calendar .month {
position: relative;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-content: flex-start;
-ms-flex-line-pack: start;
align-content: flex-start;
-webkit-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
background-color: #ffb835;
}
.flex-calendar .month .arrow,
.flex-calendar .month .label {
height: 60px;
-webkit-box-ordinal-group: 1;
-webkit-order: 0;
-ms-flex-order: 0;
order: 0;
-webkit-box-flex: 0;
-webkit-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 0 1 auto;
-webkit-align-self: auto;
-ms-flex-item-align: auto;
align-self: auto;
line-height: 60px;
font-size: 20px;
}
.flex-calendar .month .arrow {
width: 50px;
box-sizing: border-box;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABqUlEQVR4Xt3b0U3EMBCE4XEFUAolHB0clUFHUAJ0cldBkKUgnRDh7PWsd9Z5Tpz8nyxFspOCJMe2bU8AXgG8lFIurMcurIE8x9nj3wE8AvgE8MxCkAf4Ff/jTEOQBjiIpyLIAtyJpyFIAjTGUxDkADrjhxGkAIzxQwgyAIPxZgQJAFJ8RbgCOJVS6muy6QgHiIyvQqEA0fGhAArxYQAq8SEASvHTAdTipwIoxk8DUI2fAqAc7w6gHu8KkCHeDSBLvAtApng6QLZ4KkDGeBpA1ngKQOb4YYDs8UMAK8SbAVaJNwGsFN8NsFq8FeADwEPTmvPxSXV/v25xNy9fD97v8PLuVeF9FiyD0A1QKVdCMAGshGAGWAVhCGAFhGGA7AgUgMwINICsCFSAjAh0gGwILgCZENwAsiC4AmRAcAdQR5gCoIwwDUAVYSqAIsJ0ADWEEAAlhDAAFYRQAAWEcIBoBAkAIsLX/rV48291MgAEhO747o0Rr82J23GNS+6meEkAw0wwx8sCdCAMxUsDNCAMx8sD/INAiU8B8AcCLT4NwA3CG4Az68/xOu43keZ+UGLOkN4AAAAASUVORK5CYII=)
no-repeat;
background-size: contain;
background-origin: content-box;
padding: 15px 5px;
cursor: pointer;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}
.flex-calendar .month .arrow:last-child {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.flex-calendar .month .arrow.visible {
opacity: 1;
visibility: visible;
cursor: pointer;
}
.flex-calendar .month .arrow.hidden {
opacity: 0;
visibility: hidden;
cursor: default;
}
.flex-calendar .days,
.flex-calendar .week {
line-height: 25px;
font-size: 16px;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.flex-calendar .days {
background-color: #fff;
}
.flex-calendar .week {
background-color: #faac1c;
}
.flex-calendar .days .day,
.flex-calendar .week .day {
-webkit-box-flex: 0;
-webkit-flex-grow: 0;
-ms-flex-positive: 0;
flex-grow: 0;
min-width: 14.285714286%;
text-align: center;
}
.flex-calendar .days .day {
min-height: 60px;
box-sizing: border-box;
position: relative;
line-height: 60px;
border-top: 1px solid #fcfcfc;
background-color: #fff;
color: #8b8b8b;
-webkit-transition: all 0.3s ease;
transition: all 0.3s ease;
}
.flex-calendar .days .day.out {
background-color: #fcfcfc;
}
.flex-calendar .days .day.disabled.today,
.flex-calendar .days .day.today {
color: #ffb835;
border: 1px solid;
}
.flex-calendar .days .day.selected {
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.flex-calendar .days .day.selected .number {
width: 40px;
height: 40px;
background-color: #ffb835;
border-radius: 100%;
line-height: 40px;
color: #fff;
}
.flex-calendar .days .day:not(.disabled):not(.out) {
cursor: pointer;
}
.flex-calendar .days .day.disabled {
border: none;
}
.flex-calendar .days .day.disabled .number {
background-color: #efefef;
background-image: url(data:image/gif;base64,R0lGODlhBQAFAOMAAP/14////93uHt3uHt3uHt3uHv///////////wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAFAAUAAAQL0ACAzpG0YnonNxEAOw==);
}
.flex-calendar .days .day.event:before {
content: "";
width: 6px;
height: 6px;
border-radius: 100%;
background-color: #faac1c;
position: absolute;
bottom: 10px;
margin-left: -3px;
}
</style>
Step 3 – Add JavaScript
We use some external JavaScript link to this code. No need to worry about this, copy and paste below code between <head></head> tag.
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.7.2/angular-translate.js"></script>
</head>
And also copy and paste below JavaScript code between <script></script> tag.
<script>
// Git Repo: https://github.com/Russian60/flex-calendar
angular
.module("app", ["flexcalendar", "pascalprecht.translate"])
.controller("MainController", [
"$scope",
function ($scope) {
$scope.options = {
defaultDate: "2015-08-06",
minDate: "2015-01-01",
maxDate: "2015-12-31",
disabledDates: ["2015-06-22", "2015-07-27", "2015-08-13", "2015-08-15"],
dayNamesLength: 1, // 1 for "M", 2 for "Mo", 3 for "Mon"; 9 will show full day names. Default is 1.
mondayIsFirstDay: true, //set monday as first day of week. Default is false
eventClick: function (date) {
console.log(date);
},
dateClick: function (date) {
console.log(date);
},
changeMonth: function (month, year) {
console.log(month, year);
}
};
$scope.events = [
{ foo: "bar", date: "2015-08-18" },
{ foo: "bar", date: "2015-08-20" }
];
}
]);
// Library
!(function () {
"use strict";
function e() {
var e =
'<div class="flex-calendar"><div class="month"><div class="arrow {{arrowPrevClass}}" ng-click="prevMonth()"></div><div class="label">{{ selectedMonth | translate }} {{selectedYear}}</div><div class="arrow {{arrowNextClass}}" ng-click="nextMonth()"></div></div><div class="week"><div class="day" ng-repeat="day in weekDays(options.dayNamesLength) track by $index">{{ day }}</div></div><div class="days" ng-repeat="week in weeks"><div class="day"ng-repeat="day in week track by $index"ng-class="{selected: isDefaultDate(day), event: day.event[0], disabled: day.disabled, out: !day}"ng-click="onClick(day, $index, $event)"><div class="number">{{day.day}}</div></div></div></div>',
a = {
restrict: "E",
scope: { options: "=?", events: "=?" },
template: e,
controller: t
};
return a;
}
function t(e, t) {
function a() {
e.mappedDisabledDates = e.options.disabledDates.map(function (e) {
return new Date(e);
});
}
function n() {
e.mappedEvents = e.events.map(function (e) {
return (e.date = new Date(e.date)), e;
});
}
function o(t, a, n) {
t &&
!t.disabled &&
((e.options.defaultDate = t.date),
0 != t.event.length
? e.options.eventClick(t, n)
: e.options.dateClick(t, n));
}
function s(t) {
t &&
e.mappedEvents &&
((t.event = []),
e.mappedEvents.forEach(function (e) {
t.date.getFullYear() === e.date.getFullYear() &&
t.date.getMonth() === e.date.getMonth() &&
t.date.getDate() === e.date.getDate() &&
t.event.push(e);
}));
}
function i(t) {
if (!e.options.minDate && !e.options.maxDate) return !0;
var a = t.date;
return e.options.minDate && a < e.options.minDate
? !1
: e.options.maxDate && a > e.options.maxDate
? !1
: !0;
}
function d(t) {
if (!e.mappedDisabledDates) return !1;
for (var a = 0; a < e.mappedDisabledDates.length; a++)
if (
t.year === e.mappedDisabledDates[a].getFullYear() &&
t.month === e.mappedDisabledDates[a].getMonth() &&
t.day === e.mappedDisabledDates[a].getDate()
)
return !0;
}
function l() {
var t = null,
a = null;
if (!e.options.minDate) return !0;
var n = M.indexOf(e.selectedMonth);
return (
0 === n
? ((t = e.selectedYear - 1), (a = 11))
: ((t = e.selectedYear), (a = n - 1)),
t < e.options.minDate.getFullYear()
? !1
: t === e.options.minDate.getFullYear() &&
a < e.options.minDate.getMonth()
? !1
: !0
);
}
function r() {
var t = null,
a = null;
if (!e.options.maxDate) return !0;
var n = M.indexOf(e.selectedMonth);
return (
11 === n
? ((t = e.selectedYear + 1), (a = 0))
: ((t = e.selectedYear), (a = n + 1)),
t > e.options.maxDate.getFullYear()
? !1
: t === e.options.maxDate.getFullYear() &&
a > e.options.maxDate.getMonth()
? !1
: !0
);
}
function c() {
e.weeks = [];
for (
var t = null,
a = new Date(
e.selectedYear,
M.indexOf(e.selectedMonth) + 1,
0
).getDate(),
n = 1;
a + 1 > n;
n += 1
) {
var o = new Date(e.selectedYear, M.indexOf(e.selectedMonth), n),
l = new Date(e.selectedYear, M.indexOf(e.selectedMonth), n).getDay();
e.options.mondayIsFirstDay && (l = (l + 6) % 7),
(t = t || [null, null, null, null, null, null, null]),
(t[l] = {
year: e.selectedYear,
month: M.indexOf(e.selectedMonth),
day: n,
date: o,
_month: o.getMonth() + 1
}),
i(t[l]) ? e.mappedEvents && s(t[l]) : (t[l].disabled = !0),
t[l] && d(t[l]) && (t[l].disabled = !0),
(6 === l || n === a) && (e.weeks.push(t), (t = void 0));
}
(e.arrowPrevClass = e.allowedPrevMonth() ? "visible" : "hidden"),
(e.arrowNextClass = e.allowedNextMonth() ? "visible" : "hidden");
}
function D() {
(e.options._defaultDate = e.options.defaultDate
? new Date(e.options.defaultDate)
: new Date()),
(e.selectedYear = e.options._defaultDate.getFullYear()),
(e.selectedMonth = M[e.options._defaultDate.getMonth()]),
(e.selectedDay = e.options._defaultDate.getDate()),
c();
}
function p() {
if (e.mappedDisabledDates && 0 !== e.mappedDisabledDates.length) {
for (var t = 0; t < e.mappedDisabledDates.length; t++)
e.mappedDisabledDates[t] = new Date(e.mappedDisabledDates[t]);
c();
}
}
function u(e) {
return g.map(function (t) {
return m(t).slice(0, e);
});
}
function v(t) {
if (t) {
var a =
t.year === e.options._defaultDate.getFullYear() &&
t.month === e.options._defaultDate.getMonth() &&
t.day === e.options._defaultDate.getDate();
return a;
}
}
function f() {
if (e.allowedPrevMonth()) {
var t = M.indexOf(e.selectedMonth);
0 === t
? ((e.selectedYear -= 1), (e.selectedMonth = M[11]))
: (e.selectedMonth = M[t - 1]);
var a = { name: e.selectedMonth, index: t - 1, _index: t + 2 };
e.options.changeMonth(a, e.selectedYear), c();
}
}
function h() {
if (e.allowedNextMonth()) {
var t = M.indexOf(e.selectedMonth);
11 === t
? ((e.selectedYear += 1), (e.selectedMonth = M[0]))
: (e.selectedMonth = M[t + 1]);
var a = { name: e.selectedMonth, index: t + 1, _index: t + 2 };
e.options.changeMonth(a, e.selectedYear), c();
}
}
(e.days = []),
(e.options = e.options || {}),
(e.events = e.events || []),
(e.options.dayNamesLength = e.options.dayNamesLength || 1),
(e.options.mondayIsFirstDay = e.options.mondayIsFirstDay || !1),
(e.onClick = o),
(e.allowedPrevMonth = l),
(e.allowedNextMonth = r),
(e.weekDays = u),
(e.isDefaultDate = v),
(e.prevMonth = f),
(e.nextMonth = h),
(e.arrowPrevClass = "visible"),
(e.arrowNextClass = "visible");
var m = t("translate"),
M = [
"JANUARY",
"FEBRUARY",
"MARCH",
"APRIL",
"MAI",
"JUNE",
"JULY",
"AUGUST",
"SEPTEMBER",
"OCTOBER",
"NOVEMBER",
"DECEMBER"
],
g = [
"SUNDAY",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY"
];
if (e.options.mondayIsFirstDay) {
var y = g.shift();
g.push(y);
}
e.options.minDate && (e.options.minDate = new Date(e.options.minDate)),
e.options.maxDate && (e.options.maxDate = new Date(e.options.maxDate)),
e.options.disabledDates && a(),
e.events && n(),
e.$watch("options.defaultDate", function () {
D();
}),
e.$watch("options.disabledDates", function () {
a(), p();
}),
e.$watch("events", function () {
n(), c();
});
}
angular.module("flexcalendar", []).directive("flexCalendar", e),
(t.$inject = ["$scope", "$filter"]);
})();
</script>
At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.
Your Output

Video Tutorial
Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.
Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.