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.
<!--
Project to alter and expand on bootstrap carousel and card functionality forked from another project on codepen: https://codepen.io/kreigd/pen/ybYNoN/
The idea was to support mobile view in a different way and replace the bootstrap slide functionality while improving cross browser compatibility for IE10/11
This was because slide becomes a mess with some of the other work done to
use margin:auto to center the cards in an IE-compatible way.
These cards are set to a very rigid size for product displays, but
they could be swapped to flex boxes and have the contents replaced with
really anything.
-->
<div class="container-fluid">
<h1 class="text-center mb-3">Bootstrap Multi-Card Carousel</h1>
<div id="cardCarousel" class="carousel" data-ride="carousel" data-interval="false">
<div class="carousel-inner row w-80 mx-auto">
<div class="carousel-item col-md-3 active">
<div class="card offer-card">
<div class="card-body">
<div>
<h4 class="card-title compatAlignText">Lorem Ipsum 1</h4>
</div>
<ul>
<li>
<p>pulvinar lacus quis </p>
</li>
<li>
<p>lacinia sit amet.</p>
</li>
<li>
<p>Donec finibus eros ut metus</p>
</li>
<li>
<p>hendrerit</p>
</li>
</ul>
<div style="display: flex;min-height: 81px;">
<prc>$XX<sub>/mo</sub></prc>
</div>
<div>
<p style="text-align:center;" class="text-muted legalDisclaimerText compatAlignText">sit amet. <br> hendrerit Donec finibus eros
</p>
</div>
<div>
<a class="compatAlignText detailsLink">Pulvinar Eros</a>
</div>
<div style="height: 27px;">
<div class="bottomDisclaimer">
<p class="bottomDisclaimerText legalDisclaimerText compatAlignText">*lacus quis ut metus finibus eros
</p>
</div>
</div>
<div>
<div class="buttonWrapper">
<p class="compatAlignText buttonText">UTA QUIS</p>
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item col-md-3">
<div class="card offer-card">
<div class="card-body">
<div>
<h4 class="card-title compatAlignText">Lorem Ipsum 2</h4>
</div>
<ul>
<li>
<p>pulvinar lacus quis </p>
</li>
<li>
<p>lacinia sit amet.</p>
</li>
<li>
<p>Donec finibus eros ut metus</p>
</li>
<li>
<p>hendrerit</p>
</li>
</ul>
<div style="display: flex;min-height: 81px;">
<prc>$XX<sub>/mo</sub></prc>
</div>
<div>
<p style="text-align:center;" class="text-muted legalDisclaimerText compatAlignText">sit amet. <br> hendrerit Donec finibus eros
</p>
</div>
<div>
<a class="compatAlignText detailsLink">Pulvinar Eros</a>
</div>
<div style="height: 27px;">
<div class="bottomDisclaimer">
<p class="bottomDisclaimerText legalDisclaimerText compatAlignText">*lacus quis ut metus finibus eros
</p>
</div>
</div>
<div>
<div class="buttonWrapper">
<p class="compatAlignText buttonText">UTA QUIS</p>
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item col-md-3">
<div class="card offer-card">
<div class="card-body">
<div>
<h4 class="card-title compatAlignText">Lorem Ipsum 3</h4>
</div>
<ul>
<li>
<p>pulvinar lacus quis </p>
</li>
<li>
<p>lacinia sit amet.</p>
</li>
<li>
<p>Donec finibus eros ut metus</p>
</li>
<li>
<p>hendrerit</p>
</li>
</ul>
<div style="display: flex;min-height: 81px;">
<prc>$XX<sub>/mo</sub></prc>
</div>
<div>
<p style="text-align:center;" class="text-muted legalDisclaimerText compatAlignText">sit amet. <br> hendrerit Donec finibus eros
</p>
</div>
<div>
<a class="compatAlignText detailsLink">Pulvinar Eros</a>
</div>
<div style="height: 27px;">
<div class="bottomDisclaimer">
<p class="bottomDisclaimerText legalDisclaimerText compatAlignText">*lacus quis ut metus finibus eros
</p>
</div>
</div>
<div>
<div class="buttonWrapper">
<p class="compatAlignText buttonText">UTA QUIS</p>
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item col-md-3">
<div class="card offer-card">
<div class="card-body">
<div>
<h4 class="card-title compatAlignText">Lorem Ipsum 4</h4>
</div>
<ul>
<li>
<p>pulvinar lacus quis </p>
</li>
<li>
<p>lacinia sit amet.</p>
</li>
<li>
<p>Donec finibus eros ut metus</p>
</li>
<li>
<p>hendrerit</p>
</li>
</ul>
<div style="display: flex;min-height: 81px;">
<prc>$XX<sub>/mo</sub></prc>
</div>
<div>
<p style="text-align:center;" class="text-muted legalDisclaimerText compatAlignText">sit amet. <br> hendrerit Donec finibus eros
</p>
</div>
<div>
<a class="compatAlignText detailsLink">Pulvinar Eros</a>
</div>
<div style="height: 27px;">
<div class="bottomDisclaimer">
<p class="bottomDisclaimerText legalDisclaimerText compatAlignText">*lacus quis ut metus finibus eros
</p>
</div>
</div>
<div>
<div class="buttonWrapper">
<p class="compatAlignText buttonText">UTA QUIS</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="blockSwipe">
<a class="carousel-control-prev" href="#cardCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#cardCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a></div>
</div>
</div>
/* show 4 items */
/*@media (min-width: 1320px) {*/
@media (min-width: 650px) {
/* left or forward direction */
/* farthest right hidden item must be abso position for animations */
/* right or prev direction */
/* Determines visible cards
Makes active card visible, card to the right of active, card two to the right
of active visible, modify as needed.
Doesn't work when wrapping around the list.*/
#cardCarousel .carousel-inner .active,
#cardCarousel .carousel-inner .active + .carousel-item,
#cardCarousel .carousel-inner .active + .carousel-item + .carousel-item,
#cardCarousel .carousel-inner .active + .carousel-item + .carousel-item + .carousel-item {
display: block;
}
#cardCarousel .carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left),
#cardCarousel .carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left)
+ .carousel-item,
#cardCarousel .carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left)
+ .carousel-item
+ .carousel-item {
transition: none;
}
#cardCarousel .carousel-inner .carousel-item-next,
#cardCarousel .carousel-inner .carousel-item-prev {
position: relative;
/*transform: translate3d(0, 0, 0);*/
}
#cardCarousel .carousel-inner
.active.carousel-item
+ .carousel-item
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: absolute;
top: 0;
right: -33.3333%;
z-index: -1;
display: block;
visibility: visible;
}
#cardCarousel .active.carousel-item-left + .carousel-item-next.carousel-item-left,
#cardCarousel .carousel-item-next.carousel-item-left + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item,
#cardCarousel .carousel-item-next.carousel-item-left
+ .carousel-item
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: relative;
/*transform: translate3d(-100%, 0, 0);*/
visibility: visible;
}
#cardCarousel .carousel-inner .carousel-item-prev.carousel-item-right {
position: absolute;
top: 0;
left: 0;
z-index: -1;
display: block;
visibility: visible;
}
#cardCarousel .active.carousel-item-right + .carousel-item-prev.carousel-item-right,
.carousel-item-prev.carousel-item-right + .carousel-item,
#cardCarousel .carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item,
#cardCarousel .carousel-item-prev.carousel-item-right
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: relative;
/*transform: translate3d(100%, 0, 0);*/
visibility: visible;
display: block;
visibility: visible;
}
}
/*Show 3 items*/
/*@media (min-width: 1111px) and (max-width: 1320px) {
.carousel-inner .active,
.carousel-inner .active + .carousel-item,
.carousel-inner .active + .carousel-item + .carousel-item {
display: block;
}
.carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left),
.carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left)
+ .carousel-item,
.carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left)
+ .carousel-item
+ .carousel-item {
transition: none;
}
.carousel-inner .carousel-item-next,
.carousel-inner .carousel-item-prev {
position: relative;
transform: translate3d(0, 0, 0);
}
.carousel-inner
.active.carousel-item
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: absolute;
top: 0;
right: -33.3333%;
z-index: -1;
display: block;
visibility: visible;
}
/* left or forward direction */ /*
.active.carousel-item-left + .carousel-item-next.carousel-item-left,
.carousel-item-next.carousel-item-left + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item,
.carousel-item-next.carousel-item-left
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: relative;
transform: translate3d(-100%, 0, 0);
visibility: visible;
}
/* farthest right hidden item must be abso position for animations */ /*
.carousel-inner .carousel-item-prev.carousel-item-right {
position: absolute;
top: 0;
left: 0;
z-index: -1;
display: block;
visibility: visible;
}
/* right or prev direction */ /*
.active.carousel-item-right + .carousel-item-prev.carousel-item-right,
.carousel-item-prev.carousel-item-right + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item,
.carousel-item-prev.carousel-item-right
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: relative;
transform: translate3d(100%, 0, 0);
visibility: visible;
display: block;
visibility: visible;
}
}
/*show 2 items*/
/*@media (min-width: 769px) and (max-width: 1110px) {
.carousel-inner .active,
.carousel-inner .active + .carousel-item {
display: block;
}
.carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left),
.carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left)
+ .carousel-item,
.carousel-inner
.carousel-item.active:not(.carousel-item-right):not(.carousel-item-left)
+ .carousel-item
+ .carousel-item {
transition: none;
}
.carousel-inner .carousel-item-next,
.carousel-inner .carousel-item-prev {
position: relative;
transform: translate3d(0, 0, 0);
}
.carousel-inner
.active.carousel-item
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: absolute;
top: 0;
right: -33.3333%;
z-index: -1;
display: block;
visibility: visible;
}
/* left or forward direction */ /*
.active.carousel-item-left + .carousel-item-next.carousel-item-left,
.carousel-item-next.carousel-item-left + .carousel-item,
.carousel-item-next.carousel-item-left + .carousel-item + .carousel-item,
.carousel-item-next.carousel-item-left
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: relative;
transform: translate3d(-100%, 0, 0);
visibility: visible;
}
/* farthest right hidden item must be abso position for animations */ /*
.carousel-inner .carousel-item-prev.carousel-item-right {
position: absolute;
top: 0;
left: 0;
z-index: -1;
display: block;
visibility: visible;
}
/* right or prev direction */ /*
.active.carousel-item-right + .carousel-item-prev.carousel-item-right,
.carousel-item-prev.carousel-item-right + .carousel-item,
.carousel-item-prev.carousel-item-right + .carousel-item + .carousel-item,
.carousel-item-prev.carousel-item-right
+ .carousel-item
+ .carousel-item
+ .carousel-item {
position: relative;
transform: translate3d(100%, 0, 0);
visibility: visible;
display: block;
visibility: visible;
}
}*/
h1{
color: grey;
}
body{
background-color: #1c1c1c !important;
}
#cardCarousel .carousel-inner .carousel-item{
/*transition: all 1s linear;*/
}
#cardCarousel .offer-card {
height: 454px;
width: 260px;
border: none;
background-color: #2b2e4a !important;
}
#cardCarousel .carousel-inner {
width: 65%;
}
#cardCarousel .card-body ul {
margin: 0 auto;
padding: 0;
list-style: none;
text-align: center;
}
#cardCarousel .card-body ul li {
height: 42px;
width: 216px;
text-align: center;
border-top: 1px solid #afafb2;
}
#cardCarousel .card-body ul li p {
display: inline-block;
margin: 0 auto;
vertical-align: middle;
padding-top: 5px;
color: #e84545;
}
@media (max-width: 1635px) {
#cardCarousel .carousel-inner {
width: 75%;
}
}
@media (max-width: 1420px) {
#cardCarousel .carousel-inner {
width: 85%;
}
}
@media (max-width: 1320px) {
#cardCarousel .carousel-inner {
width: 51%;
}
#cardCarousel .carousel-item {
margin: auto;
max-width: 30%;
padding-bottom:15px;
}
}
@media (max-width: 1110px) {
#cardCarousel .carousel-inner {
width: 66%;
}
#cardCarousel .carousel-item {
margin: auto;
max-width: 100%;
width: 260px;
}
}
@media (max-width: 825px){
#cardCarousel .carousel-inner{
width:86%;
}
}
.blockSwipe{
display: none;
}
@media(max-width: 650px){
.blockSwipe{
display: initial;
}
#cardCarousel .carousel-inner {
width: 85% !important;
left: -2.8%;
}
#cardCarousel .carousel-inner .active + .carousel-item{
display: block;
position: absolute;
left: 90%;
opacity: 0.7;
filter: blur(1px);
animation: partialFadeIn 1s both;
}
#cardCarousel .carousel-inner .active + .carousel-item + .carousel-item + .carousel-item{
opacity: 0.7;
filter: blur(1px);
/*animation: fadeIn 1s;*/
}
#cardCarousel .carousel-item{
animation: fadeIn 1s both;
/*opacity: 0.999;*/
filter: blur(0px);
backface-visibility: hidden;
perspective: 1000;
}
}
@media(max-width:425px){
#cardCarousel .carousel-inner {
width: 95% !important;
}
}
@media(max-width:411px){
#cardCarousel .active {
display:inline-table !important;
}
#cardCarousel .carousel-inner {
width: 99% !important;
}
}
/* Text/Content Styling */
prc {
margin: auto;
height: 81px;
font-size: 62px;
position: relative;
display: inline-block;
top: -14px;
color: #e84545;
}
prc sub {
font-size: 18px;
}
#cardCarousel .card-body div {
display: flex;
display: -ms-flexbox;
/*min-height:81px;*/
}
.card-body .compatAlignText {
margin: auto;
position: relative;
display: inline-block;
}
.legalDisclaimerText {
font-size: 11px;
font-weight: 400;
color:white;
}
.detailsLink {
padding-top: 12px;
padding-bottom: 19px;
}
.bottomDisclaimer {
width: 100% !important;
position: absolute;
margin-top: 6px;
left: 0;
background-color: #53354a;
}
.bottomDisclaimer .bottomDisclaimerText {
color: white;
}
.buttonWrapper {
margin-top: -5px;
background-color: #903749;
width: 100%;
height: 48px;
position: absolute;
left: 0;
}
.buttonText {
color: white;
font-size: 20;
font-weight: 700;
}
#cardCarousel a {
text-decoration: underline !important;
color: #e84545 !important;
}
#cardCarousel h4 {
color: #e84545;
text-transform: uppercase;
}
@media (min-width: 650px) and (max-width: 1320px) {
#cardCarousel .carousel-inner .carousel-item {
-webkit-box-flex: 0 !important;
-ms-flex: 0 0 50% !important;
flex: 0 0 50% !important;
max-width: 50% !important;
}
}
@keyframes fadeIn{
0% {
opacity: 0.5;
/*filter: blur(2px);*/
}
100% {
opacity: 0.999;
/*filter: blur(0px);*/
}
}
@keyframes partialFadeIn{
0% {
opacity: 0.1;
filter: blur(2px);
}
100% {
opacity: 0.7;
filter: blur(1px);
}
}
$(document).ready(function () {
$("#cardCarousel").on("slide.bs.carousel", function (e) {
var $e = $(e.relatedTarget);
var idx = $e.index();
var itemsPerSlide = 4;
var totalItems = $(".carousel-item").length;
var width = window.innerWidth;
//sets the supported items per slide based on window width, currently
//hardcoded as you can see.
//also need css corisponding to support the number of cards
//at that vw.
//see commented out css for "show 3 items"
if (width >= 1321) {
itemsPerSlide = 4;
}
if (width <= 1320) {
itemsPerSlide = 3;
}
if (width <= 1110) {
itemsPerSlide = 2;
}
if (width <= 769) {
itemsPerSlide = 1;
}
if (idx >= totalItems - (itemsPerSlide - 1)) {
var it = itemsPerSlide - (totalItems - idx);
for (var i = 0; i < it; i++) {
// append slides to end
if (e.direction == "left") {
$(".carousel-item")
.eq(i)
.appendTo(".carousel-inner");
} else {
$(".carousel-item")
.eq(0)
.appendTo($(this).find(".carousel-inner"));
}
}
}
});
});
/**
* Bootstrap Carousel Swipe v1.1
*
* jQuery plugin to enable swipe gestures on Bootstrap 3 carousels.
* Examples and documentation: https://github.com/maaaaark/bcSwipe
*
* Licensed under the MIT license.
*/
(function ($) {
var supportsPassive = false;
$.fn.bcSwipe = function (settings) {
var config = { threshold: 50, pixelLimit: 768 }; //pixel limit determines view width swipe enables at.
if (settings) {
$.extend(config, settings);
}
this.each(function () {
var stillMoving = false;
var start;
if ('ontouchstart' in document.documentElement) {
this.addEventListener('touchstart', onTouchStart, supportsPassive ? { passive: true } : false);
}
function onTouchStart(e) {
if (e.touches.length == 1) {
start = e.touches[0].pageX;
stillMoving = true;
this.addEventListener('touchmove', onTouchMove, supportsPassive ? { passive: true } : false);
}
}
function onTouchMove(e) {
if (stillMoving) {
var x = e.touches[0].pageX;
var difference = start - x;
if (Math.abs(difference) >= config.threshold) {
cancelTouch();
//checks window width before allowing swiping next/prev.
if (difference > 0 && config.pixelLimit >= window.innerWidth) {
$(this).carousel('next');
}
else if (config.pixelLimit >= window.innerWidth) {
$(this).carousel('prev');
}
}
}
}
function cancelTouch() {
this.removeEventListener('touchmove', onTouchMove);
start = null;
stillMoving = false;
}
});
return this;
};
})(jQuery);
window.onload = function () {
$('#cardCarousel').bcSwipe({
threshold: 50,
pixelLimit: 768
});
}
Also see: Tab Triggers