HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body>
<main class="cd-main-content">
<div class="cd-tab-filter-wrapper">
<div class="cd-tab-filter">
<ul class="cd-filters">
<li class="placeholder">
<a data-type="all" style="cursor: none;" href="#0">All</a> <!-- selected option on mobile -->
</li>
<li class="filter"><a class="selected" style="cursor: none;" href="#0" data-type="all">Home</a></li>
<li class="filter" data-filter=".color-1"><a href="#0" style="cursor: none;" data-type="color-1">Availability</a></li>
<li class="filter" data-filter=".color-2"><a href="#0" style="cursor: none;" data-type="color-2">Area Map</a></li>
</ul> <!-- cd-filters -->
</div> <!-- cd-tab-filter -->
</div> <!-- cd-tab-filter-wrapper -->
<div id='map2'></div>
<div class="cd-filter">
<form>
<div class="cd-filter-block">
<h4>Search</h4>
<div class="cd-filter-content">
<input type="search" placeholder="Neighborhood...">
</div> <!-- cd-filter-content -->
</div> <!-- cd-filter-block -->
<div class="cd-filter-block">
<h4>Category</h4>
<ul class="cd-filter-content cd-filters list">
<li>
<input class="filter" data-filter=".check1" type="checkbox" id="checkbox1">
<label class="checkbox-label" for="checkbox1">Residential</label>
</li>
<li>
<input class="filter" data-filter=".check2" type="checkbox" id="checkbox2">
<label class="checkbox-label" for="checkbox2">Schools</label>
</li>
<li>
<input class="filter" data-filter=".check3" type="checkbox" id="checkbox3">
<label class="checkbox-label" for="checkbox3">Dining</label>
</li>
<li>
<input class="filter" data-filter=".check3" type="checkbox" id="checkbox3">
<label class="checkbox-label" for="checkbox3">Parks</label>
</li>
<li>
<input class="filter" data-filter=".check3" type="checkbox" id="checkbox3">
<label class="checkbox-label" for="checkbox3">Health & Wellness</label>
</li>
<li>
<input class="filter" data-filter=".check3" type="checkbox" id="checkbox3">
<label class="checkbox-label" for="checkbox3">Commercial</label>
</li>
</ul> <!-- cd-filter-content -->
</div> <!-- cd-filter-block -->
<div class="cd-filter-block">
<h4>Builders</h4>
<div class="cd-filter-content">
<div class="cd-select cd-filters">
<select class="filter" name="selectThis" id="selectThis">
<option value="">Choose an option</option>
<option value=".option1">American Legend Homes</option>
<option value=".option2">Darling Homes</option>
<option value=".option3">Drees Homes</option>
<option value=".option3">Highland Homes</option>
<option value=".option4">Horizon Homes</option>
<option value=".option4">Lionsgate Homes</option>
<option value=".option4">Shaddock Homes</option>
</select>
</div> <!-- cd-select -->
</div> <!-- cd-filter-content -->
</div> <!-- cd-filter-block -->
<div class="cd-filter-block">
<h4>Drive Times</h4>
<ul class="cd-filter-content cd-filters list">
<li>
<input class="filter" data-filter="" type="radio" name="radioButton" id="radio1" checked>
<label class="radio-label" for="radio1">All</label>
</li>
<li>
<input class="filter" data-filter=".radio2" type="radio" name="radioButton" id="radio2">
<label class="radio-label" for="radio2">10 Min</label>
</li>
<li>
<input class="filter" data-filter=".radio3" type="radio" name="radioButton" id="radio3">
<label class="radio-label" for="radio3">20 Min</label>
</li>
</ul> <!-- cd-filter-content -->
</div> <!-- cd-filter-block -->
</form>
<a href="#0" class="cd-close">Close</a>
</div> <!-- cd-filter -->
<a href="#0" class="cd-filter-trigger">Filters</a>
</main> <!-- cd-main-content -->
<div class="cursor loaded"></div>
</body>
</html>
/* --------------------------------
Primary style
-------------------------------- */
*, *::after, *::before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
html * {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body {
font-size: 1.6rem;
font-family: "Open Sans", sans-serif;
color: #331d35;
background-color: #e7e7e7;
}
a {
color: #41307c;
text-decoration: none;
}
/* --------------------------------
Main Components
-------------------------------- */
.cd-header {
position: relative;
height: 150px;
background-color: #331d35;
}
.cd-header h1 {
color: #ffffff;
line-height: 150px;
text-align: center;
font-size: 2.4rem;
font-weight: 300;
}
@media only screen and (min-width: 1170px) {
.cd-header {
height: 180px;
}
.cd-header h1 {
line-height: 180px;
}
}
.cd-main-content {
position: relative;
min-height: 100vh;
}
.cd-main-content:after {
content: "";
display: table;
clear: both;
}
.cd-main-content.is-fixed .cd-tab-filter-wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
}
.cd-main-content.is-fixed .cd-gallery {
padding-top: 76px;
}
.cd-main-content.is-fixed .cd-filter {
position: fixed;
height: 100vh;
overflow: hidden;
}
.cd-main-content.is-fixed .cd-filter form {
height: 100vh;
overflow: auto;
-webkit-overflow-scrolling: touch;
}
.cd-main-content.is-fixed .cd-filter-trigger {
position: fixed;
}
@media only screen and (min-width: 768px) {
.cd-main-content.is-fixed .cd-gallery {
padding-top: 90px;
}
}
@media only screen and (min-width: 1170px) {
.cd-main-content.is-fixed .cd-gallery {
padding-top: 100px;
}
}
/* --------------------------------
xtab-filter
-------------------------------- */
.cd-tab-filter-wrapper {
background-color: #ffffff;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
z-index: 1;
}
.cd-tab-filter-wrapper:after {
content: "";
display: table;
clear: both;
}
.cd-tab-filter {
/* tabbed navigation style on mobile - dropdown */
position: relative;
height: 50px;
width: 140px;
margin: 0 auto;
z-index: 1;
}
.cd-tab-filter::after {
/* small arrow icon */
content: '';
position: absolute;
right: 14px;
top: 50%;
bottom: auto;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
display: inline-block;
width: 16px;
height: 16px;
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/8426/cd-icon-arrow.svg") no-repeat center center;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
pointer-events: none;
}
.cd-tab-filter ul {
position: absolute;
top: 0;
left: 0;
background-color: #ffffff;
box-shadow: inset 0 -2px 0 #41307c;
}
.cd-tab-filter li {
display: none;
}
.cd-tab-filter li:first-child {
/* this way the placehodler is alway visible */
display: block;
}
.cd-tab-filter a {
display: block;
/* set same size of the .cd-tab-filter */
height: 50px;
width: 140px;
line-height: 50px;
padding-left: 14px;
}
.cd-tab-filter a.selected {
background: #41307c;
color: #ffffff;
}
.cd-tab-filter.is-open::after {
/* small arrow rotation */
-webkit-transform: translateY(-50%) rotate(-180deg);
-moz-transform: translateY(-50%) rotate(-180deg);
-ms-transform: translateY(-50%) rotate(-180deg);
-o-transform: translateY(-50%) rotate(-180deg);
transform: translateY(-50%) rotate(-180deg);
}
.cd-tab-filter.is-open ul {
box-shadow: inset 0 -2px 0 #41307c, 0 2px 10px rgba(0, 0, 0, 0.2);
}
.cd-tab-filter.is-open ul li {
display: block;
}
.cd-tab-filter.is-open .placeholder a {
/* reduces the opacity of the placeholder on mobile when the menu is open */
opacity: .4;
}
@media only screen and (min-width: 768px) {
.cd-tab-filter {
/* tabbed navigation style on medium devices */
width: auto;
cursor: auto;
}
.cd-tab-filter::after {
/* hide the arrow */
display: none;
}
.cd-tab-filter ul {
background: transparent;
position: static;
box-shadow: none;
text-align: center;
}
.cd-tab-filter li {
display: inline-block;
}
.cd-tab-filter li.placeholder {
display: none !important;
}
.cd-tab-filter a {
display: inline-block;
padding: 0 1em;
width: auto;
color: #9a9a9a;
text-transform: uppercase;
font-weight: 700;
font-size: 1.3rem;
}
.no-touch .cd-tab-filter a:hover {
color: #41307c;
}
.cd-tab-filter a.selected {
background: transparent;
color: #41307c;
/* create border bottom using box-shadow property */
box-shadow: inset 0 -2px 0 #41307c;
}
.cd-tab-filter.is-open ul li {
display: inline-block;
}
}
@media only screen and (min-width: 1170px) {
.cd-tab-filter {
/* tabbed navigation on big devices */
width: 100%;
float: right;
margin: 0;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
transition: width 0.3s;
}
.cd-tab-filter.filter-is-visible {
/* reduce width when filter is visible */
width: 80%;
}
}
/* --------------------------------
xgallery
-------------------------------- */
.cd-gallery {
padding: 26px 5%;
width: 100%;
}
.cd-gallery li {
margin-bottom: 1.6em;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
display: none;
}
.cd-gallery li.gap {
/* used in combination with text-align: justify to align gallery elements */
opacity: 0;
height: 0;
display: inline-block;
}
.cd-gallery img {
display: block;
width: 100%;
}
.cd-gallery .cd-fail-message {
display: none;
text-align: center;
}
@media only screen and (min-width: 768px) {
.cd-gallery {
padding: 40px 3%;
}
.cd-gallery ul {
text-align: justify;
}
.cd-gallery ul:after {
content: "";
display: table;
clear: both;
}
.cd-gallery li {
width: 48%;
margin-bottom: 2em;
}
}
@media only screen and (min-width: 1170px) {
.cd-gallery {
padding: 50px 2%;
float: right;
-webkit-transition: width 0.3s;
-moz-transition: width 0.3s;
transition: width 0.3s;
}
.cd-gallery li {
width: 23%;
}
.cd-gallery.filter-is-visible {
/* reduce width when filter is visible */
width: 80%;
}
}
/* --------------------------------
xfilter
-------------------------------- */
.cd-filter {
position: absolute;
top: 0;
left: 0;
width: 280px;
height: 100%;
background: #ffffff;
box-shadow: 4px 4px 20px transparent;
z-index: 2;
/* Force Hardware Acceleration in WebKit */
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transform: translateX(-100%);
-moz-transform: translateX(-100%);
-ms-transform: translateX(-100%);
-o-transform: translateX(-100%);
transform: translateX(-100%);
-webkit-transition: -webkit-transform 0.3s, box-shadow 0.3s;
-moz-transition: -moz-transform 0.3s, box-shadow 0.3s;
transition: transform 0.3s, box-shadow 0.3s;
}
.cd-filter::before {
/* top colored bar */
content: '';
position: absolute;
top: 0;
left: 0;
height: 50px;
width: 100%;
background-color: #41307c;
z-index: 2;
}
.cd-filter form {
padding: 70px 20px;
}
.cd-filter .cd-close {
position: absolute;
top: 0;
right: 0;
height: 50px;
line-height: 50px;
width: 60px;
color: #ffffff;
font-size: 1.3rem;
text-align: center;
background: #37296a;
opacity: 0;
-webkit-transition: opacity 0.3s;
-moz-transition: opacity 0.3s;
transition: opacity 0.3s;
z-index: 3;
}
.no-touch .cd-filter .cd-close:hover {
background: #32255f;
}
.cd-filter.filter-is-visible {
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-o-transform: translateX(0);
transform: translateX(0);
box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.2);
}
.cd-filter.filter-is-visible .cd-close {
opacity: 1;
}
@media only screen and (min-width: 1170px) {
.cd-filter {
width: 20%;
}
.cd-filter form {
padding: 70px 10%;
}
}
.cd-filter-trigger {
position: absolute;
top: 0;
left: 0;
height: 50px;
line-height: 50px;
width: 60px;
/* image replacement */
overflow: hidden;
text-indent: 100%;
color: transparent;
white-space: nowrap;
background: transparent url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/8426/cd-icon-filter.svg") no-repeat center center;
z-index: 3;
}
.cd-filter-trigger.filter-is-visible {
pointer-events: none;
}
@media only screen and (min-width: 1170px) {
.cd-filter-trigger {
width: auto;
left: 2%;
text-indent: 0;
color: #9a9a9a;
text-transform: uppercase;
font-size: 1.3rem;
font-weight: 700;
padding-left: 24px;
background-position: left center;
-webkit-transition: color 0.3s;
-moz-transition: color 0.3s;
transition: color 0.3s;
}
.no-touch .cd-filter-trigger:hover {
color: #41307c;
}
.cd-filter-trigger.filter-is-visible, .cd-filter-trigger.filter-is-visible:hover {
color: #ffffff;
}
}
/* --------------------------------
xcustom form elements
-------------------------------- */
.cd-filter-block {
margin-bottom: 1.6em;
}
.cd-filter-block h4 {
/* filter block title */
position: relative;
margin-bottom: .2em;
padding: 10px 0 10px 20px;
color: #9a9a9a;
text-transform: uppercase;
font-weight: 700;
font-size: 1.3rem;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
cursor: pointer;
}
.no-touch .cd-filter-block h4:hover {
color: #41307c;
}
.cd-filter-block h4::before {
/* arrow */
content: '';
position: absolute;
left: 0;
top: 50%;
width: 16px;
height: 16px;
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/8426/cd-icon-arrow.svg") no-repeat center center;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
-webkit-transition: -webkit-transform 0.3s;
-moz-transition: -moz-transform 0.3s;
transition: transform 0.3s;
}
.cd-filter-block h4.closed::before {
-webkit-transform: translateY(-50%) rotate(-90deg);
-moz-transform: translateY(-50%) rotate(-90deg);
-ms-transform: translateY(-50%) rotate(-90deg);
-o-transform: translateY(-50%) rotate(-90deg);
transform: translateY(-50%) rotate(-90deg);
}
.cd-filter-block input, .cd-filter-block select,
.cd-filter-block .radio-label::before,
.cd-filter-block .checkbox-label::before {
/* shared style for input elements */
font-family: "Open Sans", sans-serif;
border-radius: 0;
background-color: #ffffff;
border: 2px solid #e6e6e6;
}
.cd-filter-block input[type='search'],
.cd-filter-block input[type='text'],
.cd-filter-block select {
width: 100%;
padding: .8em;
-webkit-appearance: none;
-moz-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
box-shadow: none;
}
.cd-filter-block input[type='search']:focus,
.cd-filter-block input[type='text']:focus,
.cd-filter-block select:focus {
outline: none;
background-color: #ffffff;
border-color: #41307c;
}
.cd-filter-block input[type='search'] {
/* custom style for the search element */
border-color: transparent;
background-color: #e6e6e6;
/* prevent jump - ios devices */
font-size: 1.6rem !important;
}
.cd-filter-block input[type='search']::-webkit-search-cancel-button {
display: none;
}
.cd-filter-block .cd-select {
/* select element wrapper */
position: relative;
}
.cd-filter-block .cd-select::after {
/* switcher arrow for select element */
content: '';
position: absolute;
z-index: 1;
right: 14px;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
display: block;
width: 16px;
height: 16px;
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/8426/cd-icon-arrow.svg") no-repeat center center;
pointer-events: none;
}
.cd-filter-block select {
cursor: pointer;
font-size: 1.4rem;
}
.cd-filter-block select::-ms-expand {
display: none;
}
.cd-filter-block .list li {
position: relative;
margin-bottom: .8em;
}
.cd-filter-block .list li:last-of-type {
margin-bottom: 0;
}
.cd-filter-block input[type=radio],
.cd-filter-block input[type=checkbox] {
/* hide original check and radio buttons */
position: absolute;
left: 0;
top: 0;
margin: 0;
padding: 0;
opacity: 0;
z-index: 2;
}
.cd-filter-block .checkbox-label,
.cd-filter-block .radio-label {
padding-left: 24px;
font-size: 1.4rem;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.cd-filter-block .checkbox-label::before, .cd-filter-block .checkbox-label::after,
.cd-filter-block .radio-label::before,
.cd-filter-block .radio-label::after {
/* custom radio and check boxes */
content: '';
display: block;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
}
.cd-filter-block .checkbox-label::before,
.cd-filter-block .radio-label::before {
width: 16px;
height: 16px;
left: 0;
}
.cd-filter-block .checkbox-label::after,
.cd-filter-block .radio-label::after {
/* check mark - hidden */
display: none;
}
.cd-filter-block .checkbox-label::after {
/* check mark style for check boxes */
width: 16px;
height: 16px;
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/8426/cd-icon-arrow.svg") no-repeat center center;
}
.cd-filter-block .radio-label::before,
.cd-filter-block .radio-label::after {
border-radius: 50%;
}
.cd-filter-block .radio-label::after {
/* check mark style for radio buttons */
width: 6px;
height: 6px;
background-color: #ffffff;
left: 5px;
}
.cd-filter-block input[type=radio]:checked + label::before,
.cd-filter-block input[type=checkbox]:checked + label::before {
border-color: #41307c;
background-color: #41307c;
}
.cd-filter-block input[type=radio]:checked + label::after,
.cd-filter-block input[type=checkbox]:checked + label::after {
display: block;
}
@-moz-document url-prefix() {
/* hide custom arrow on Firefox - select element */
.cd-filter-block .cd-select::after {
display: none;
}
}
.cursor {
position: absolute;
top: 10px;
left: 10px;
width: 20px;
height: 20px;
z-index: 999;
pointer-events: none;
background: #fff;
border-radius: 50%;
opacity: .8;
pointer: none;
box-shadow: 5px 5px 20px rgba(0,0,0,.4), 0 1px 6px rgba(0,0,0,.22);
}
.cursor:before {
z-index: 2;
background: #8367d8;
-webkit-transition: all .2s ease-out .1s;
transition: all .2s ease-out .1s;
}
.cursor:after, .cursor:before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1;
border-radius: 50%;
background: #3edfcd;
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transition: all .2s ease-out;
transition: all .2s ease-out;
}
#map2 { position:absolute; top:50px; bottom:0; width:100%; }
.mapboxgl-popup {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
padding: 2px 20px 0 0;
width: 350px;
right:50px;
position: relative;
}
.mapboxgl-popup-content {
position: relative;
text-align: left;
font-family: 'din-2014', sans-serif;
background: rgba(21,34,53,0.9);
color: rgba(256,256,256,0.8);
border-radius: 0px;
box-shadow: 0 1px 2px rgba(0,0,0,0.10);
padding: 10px 20px;
pointer-events: auto;
box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.mapboxgl-popup-content h3 {
text-align: left;
font-family: 'din-2014', sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
}
.mapboxgl-popup-content p {
text-align: left;
font-family: 'din-2014', sans-serif;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
}
.mapboxgl-popup-close-button {
position: absolute;
right: 0;
top: 0;
border: none;
border-radius: 0 0px 0 0;
cursor: pointer;
background-color: rgba(256,256,256,0);
color: rgba(256,256,256,0.8);
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
font-size: 20px;
}
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
border-top-color: rgba(21,34,53,0.9);
}
.marker {
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/8426/map-marker.svg');
background-size: cover;
width: 30px;
height: 50px;
cursor: pointer;
}
/* Zoom Contrial */
.mapboxgl-ctrl-group {
border-radius: 0px;
-moz-box-shadow: 0px 0px 2px rgba(0,0,0,0.1);
-webkit-box-shadow: 0px 0px 2px rgba(0,0,0,0.1);
box-shadow: 0px 0px 0px 2px rgba(0,0,0,0.1);
overflow: hidden;
background: #fff;
}
.mapboxgl-ctrl-group > button {
width: 30px;
height: 30px;
display: block;
padding: 0;
outline: none;
border: none;
border-bottom: 1px solid #ddd;
box-sizing: border-box;
background-color: rgba(0,0,0,0);
cursor: pointer;
}
jQuery(document).ready(function($){
//open/close lateral filter
$('.cd-filter-trigger').on('click', function(){
triggerFilter(true);
});
$('.cd-filter .cd-close').on('click', function(){
triggerFilter(false);
});
function triggerFilter($bool) {
var elementsToTrigger = $([$('.cd-filter-trigger'), $('.cd-filter'), $('.cd-tab-filter'), $('.cd-gallery')]);
elementsToTrigger.each(function(){
$(this).toggleClass('filter-is-visible', $bool);
});
}
//mobile version - detect click event on filters tab
var filter_tab_placeholder = $('.cd-tab-filter .placeholder a'),
filter_tab_placeholder_default_value = 'Select',
filter_tab_placeholder_text = filter_tab_placeholder.text();
$('.cd-tab-filter li').on('click', function(event){
//detect which tab filter item was selected
var selected_filter = $(event.target).data('type');
//check if user has clicked the placeholder item
if( $(event.target).is(filter_tab_placeholder) ) {
(filter_tab_placeholder_default_value == filter_tab_placeholder.text()) ? filter_tab_placeholder.text(filter_tab_placeholder_text) : filter_tab_placeholder.text(filter_tab_placeholder_default_value) ;
$('.cd-tab-filter').toggleClass('is-open');
//check if user has clicked a filter already selected
} else if( filter_tab_placeholder.data('type') == selected_filter ) {
filter_tab_placeholder.text($(event.target).text());
$('.cd-tab-filter').removeClass('is-open');
} else {
//close the dropdown and change placeholder text/data-type value
$('.cd-tab-filter').removeClass('is-open');
filter_tab_placeholder.text($(event.target).text()).data('type', selected_filter);
filter_tab_placeholder_text = $(event.target).text();
//add class selected to the selected filter item
$('.cd-tab-filter .selected').removeClass('selected');
$(event.target).addClass('selected');
}
});
//close filter dropdown inside lateral .cd-filter
$('.cd-filter-block h4').on('click', function(){
$(this).toggleClass('closed').siblings('.cd-filter-content').slideToggle(300);
})
//fix lateral filter and gallery on scrolling
$(window).on('scroll', function(){
(!window.requestAnimationFrame) ? fixGallery() : window.requestAnimationFrame(fixGallery);
});
function fixGallery() {
var offsetTop = $('.cd-main-content').offset().top,
scrollTop = $(window).scrollTop();
( scrollTop >= offsetTop ) ? $('.cd-main-content').addClass('is-fixed') : $('.cd-main-content').removeClass('is-fixed');
}
/************************************
MitItUp filter settings
More details:
https://mixitup.kunkalabs.com/
or:
https://codepen.io/patrickkunka/
*************************************/
buttonFilter.init();
$('.cd-gallery ul').mixItUp({
controls: {
enable: false
},
callbacks: {
onMixStart: function(){
$('.cd-fail-message').fadeOut(200);
},
onMixFail: function(){
$('.cd-fail-message').fadeIn(200);
}
}
});
//search filtering
//credits https://codepen.io/edprats/pen/pzAdg
var inputText;
var $matching = $();
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$(".cd-filter-content input[type='search']").keyup(function(){
// Delay function invoked to make sure user stopped typing
delay(function(){
inputText = $(".cd-filter-content input[type='search']").val().toLowerCase();
// Check to see if input field is empty
if ((inputText.length) > 0) {
$('.mix').each(function() {
var $this = $(this);
// add item to be filtered out if input text matches items inside the title
if($this.attr('class').toLowerCase().match(inputText)) {
$matching = $matching.add(this);
} else {
// removes any previously matched item
$matching = $matching.not(this);
}
});
$('.cd-gallery ul').mixItUp('filter', $matching);
} else {
// resets the filter to show all item if input is empty
$('.cd-gallery ul').mixItUp('filter', 'all');
}
}, 200 );
});
});
$('body').mouseover(function(){
$(this).css({cursor: 'none'});
});
$(document).on('mousemove', function(e){
$('.cursor').css({
left: e.pageX,
top: e.pageY
});
});
mapboxgl.accessToken = 'pk.eyJ1IjoiYWxhc3NldHRlciIsImEiOiI3andLQ1MwIn0.1q6yuZJaMCnAW0cm_6vy_A';
var map = new mapboxgl.Map({
container: 'map2',
style: 'mapbox://styles/alassetter/cj802ea3y7c0y2so1kr69uzr7',
center: [-97.390284, 32.742311],
zoom: 11.84,
bearing: 0,
pitch: 45
});
// Add zoom and rotation controls to the map.
map.addControl(new mapboxgl.NavigationControl());
var geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"address": "1 Lockheed Boulevard, Fort Worth, TX 76108",
"title": "Lockhead Martin Corporation"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.450327,
32.772316
]
},
"id": "22a8e5c7a78d4b197b034461190ad38f"
},
{
"type": "Feature",
"properties": {
"address": "1510 Chennault Ave, Fort Worth, TX 76113",
"title": "Naval Air Station Joint Reserve Base"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.431274,
32.76635
]
},
"id": "44e6693de043f060289a783885361975"
},
{
"type": "Feature",
"properties": {
"address": "1989 Colonial Pkwy, Fort Worth, TX 76110",
"title": "Fort Worth Zoo"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.355268,
32.719962
]
},
"id": "53a3823f2787343545b41956a11d7436"
},
{
"type": "Feature",
"properties": {
"address": "201 American Concourse, Fort Worth, TX 76106",
"title": "Fort Worth Meacham Int'l Airport"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.361446,
32.81861
]
},
"id": "9008333ca64bd9cb8c280dc26b8ce179"
},
{
"type": "Feature",
"properties": {
"address": "2800 S University Dr, Fort Worth, TX 76129",
"title": "TCU"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.36227750778198,
32.708787533790954
]
}
},
{
"type": "Feature",
"properties": {
"address": "130 E Exchange Ave, Fort Worth, TX 76164",
"title": "Fort Worth Stockyards"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.34665632247925,
32.78904685910516
]
}
},
{
"type": "Feature",
"properties": {
"title": "Fort Worth Botanical Gardens",
"address": " 3220 Botanic Garden Blvd, Fort Worth, TX 76107"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.36373662948608,
32.73839295758385
]
}
},
{
"type": "Feature",
"properties": {
"title": "Museum District",
"address": "1600 Gendy St, Fort Worth, TX 76107"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.36573219299316,
32.74480015438575
]
}
},
{
"type": "Feature",
"properties": {
"address": " 900 8th Ave, Fort Worth, TX 76104",
"title": "Medical District"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.34550833702087,
32.73018926836491
]
}
},
{
"type": "Feature",
"properties": {
"title": "Convention Center",
"address": "1201 Houston St, Fort Worth, TX 76102"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.32813835144043,
32.74988948658023
]
}
},
{
"type": "Feature",
"properties": {
"title": "Future Home of Cooks Children's Medical Facility",
"address": "Coming Soon"
},
"geometry": {
"type": "Point",
"coordinates": [
-97.56101846694946,
32.718897808047416
]
}
}
]
};
// add markers to map
geojson.features.forEach(function(marker) {
// create a HTML element for each feature
var el = document.createElement('div');
el.className = 'marker';
// make a marker for each feature and add to the map
new mapboxgl.Marker(el, { offset: [-0 / 0.5, -0 / 0.5] })
.setLngLat(marker.geometry.coordinates)
.setPopup(new mapboxgl.Popup({ offset: 40 }) // add popups
.setHTML('<h3>' + marker.properties.title + '</h3><p>' + marker.properties.address + '</p>'))
.addTo(map);
});
Also see: Tab Triggers