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.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta charset="utf-8">
<title>Flexbox Testimonials</title>
</head>
<body>
<div class="col-sm-7 mx-auto">
<header class="section-header text-center">
<span class="h1 d-block">
<span>❝</span>
</span>
<h2>Happy Customers</h2>
</header>
</div>
<div id="flex-container" class="testimonials">
<div id="left-zone">
<ul class="list">
<li class="item">
<input type="radio" id="radio_testimonial-1" name="basic_carousel" checked="checked" />
<label class="label_testimonial-1" for="radio_testimonial-1">Diamond Pest Elimination</label>
<div class="content-test content_testimonial-1">
<span class="picto"></span>
<h1>Diamond Pest Elimination</h1>
<p>“The team really takes pride in their work. If I didn’t know any better I would think they actually worked for my company.”</p>
<p class="testimonialFrom">Bill, Owner</p>
<p class="testimonialState">Rochester, NY</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_testimonial-2" name="basic_carousel" />
<label class="label_testimonial-2" for="radio_testimonial-2">A+ Handyman Service</label>
<div class="content-test content_testimonial-2">
<span class="picto"></span>
<h1>A+ Handyman Service</h1>
<p>“Quite simply… the service offers prompt response time to my visitors and helps me to better know what type of project a potential customer wants.”</p>
<p class="testimonialFrom">Bill, Owner</p>
<p class="testimonialState">Tucson, AZ</p>
<br>
</div>
</li>
<li class="item">
<input type="radio" id="radio_testimonial-3" name="basic_carousel" />
<label class="label_testimonial-3" for="radio_testimonial-3">Mod Movers</label>
<div class="content-test content_testimonial-3">
<span class="picto"></span>
<h1>Mod Movers</h1>
<p>“I couldn’t believe it. I actually had to hire someone to help me keep up with the new business. I had no idea my website had so much value.”</p>
<p class="testimonialFrom">Marlene, Owner</p>
<p class="testimonialState">Monterey, CA</p>
</div>
</li>
<li class="item">
<input type="radio" id="radio_testimonial-4" name="basic_carousel" />
<label class="label_testimonial-4" for="radio_testimonial-4">AK Pest Control</label>
<div class="content-test content_testimonial-4">
<span class="picto"></span>
<h1>AK Pest Control</h1>
<p>Great company to send leads. Very efficient and pleased with the services. We get lots of leads and that whats important. Support is also great from the managers/support. Thanks YPC Chat</p>
<p class="testimonialFrom">Mark, Owner</p>
<p class="testimonialState">Somerset, VA</p>
<br>
</div>
</li>
</ul>
</div>
<div id="right-zone"></div>
</div>
</body>
</html>
body {
background: #eee;
font-family: Tahoma;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
padding-top: 20px;
}
.d-block, h2{
color: #33475c;
font-weight: 700;
font-size: 2.5rem;
display: block;
margin: 0 auto;
text-align: center;
padding-bottom: 20px;
}
/* ============= Begin Testimonial Flexbox ============ */
#flex-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
min-height: 400px;
height: 110vh;
max-width: 1000px;
margin: auto;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
overflow: hidden;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
position: relative;
}
#left-zone {
height: 50%;
-webkit-box-flex: 0;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: 100%;
}
#left-zone .list {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
list-style: none;
-ms-flex-line-pack: stretch;
align-content: stretch;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-flex: 1;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
margin: auto;
padding: 0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.item input {
display: none;
}
label {
display: block;
opacity: 0.5;
height: 50px;
text-align: center;
line-height: 50px;
position: relative;
}
label:hover {
opacity: 0.75;
cursor: pointer;
}
.content-test {
position: absolute;
right: 0;
bottom: 0;
opacity: 0;
-webkit-transform: translateY(100%);
-ms-transform: translateY(100%);
transform: translateY(100%);
height: 50%;
width: 100%;
-webkit-transition: 0.5s ease-out;
-o-transition: 0.5s ease-out;
transition: 0.5s ease-out;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
pointer-events: none;
}
.content-test p {
max-width: 50%;
text-align: center;
}
#right-zone {
width: 100%;
-webkit-box-flex: 1;
-ms-flex: 1 0 auto;
flex: 1 0 auto;
height: 50%;
}
input:checked ~ .content-test {
-webkit-transform: translateY(0%);
-ms-transform: translateY(0%);
transform: translateY(0%);
-webkit-transition: -webkit-transform 1s;
transition: -webkit-transform 1s;
-o-transition: transform 1s;
transition: transform 1s;
transition: transform 1s, -webkit-transform 1s;
opacity: 1;
}
@media (min-width: 480px) {
#flex-container {
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
min-height: auto;
height: 400px;
/* position: absolute; */
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#left-zone .list {
border-right: 2px solid #cccccc;
}
.content-test {
width: 65%;
height: 100%;
pointer-events: auto;
-webkit-transform: translateY(-100%);
-ms-transform: translateY(-100%);
transform: translateY(-100%);
}
#left-zone {
width: 35%;
}
#right-zone {
height: 100%;
width: 65%;
}
}
/* If the screen size is 480px or less */
@media (max-width: 480px) {
.content_testimonial-1 .picto {
padding-top: 100px;
}
.content_testimonial-2 .picto {
padding-top: 100px;
}
.content_testimonial-3 .picto {
padding-top: 100px;
}
.content_testimonial-4 .picto {
padding-top: 100px;
}
.item > label {
font-size: 1.3rem;
}
}
.content_testimonial-1 .picto {
height: 100px;
width: 100px;
background-image: url("https://i.postimg.cc/RFBHkG46/diamond-Pest-Logo-small.jpg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.content_testimonial-1 h1 {
color: #d64541;
text-align: center;
}
.content_testimonial-2 .picto {
height: 100px;
width: 100px;
background-image: url("https://i.postimg.cc/bsqXXKCV/a-Plus-Handyman-Logo.jpg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.content_testimonial-2 h1 {
color: #f5d76e;
}
.content_testimonial-3 .picto {
height: 100px;
width: 100px;
background-image: url("https://i.postimg.cc/zV7sq04z/mod-Movers-Logo.jpg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.content_testimonial-3 h1 {
color: #00b16a;
}
.content_testimonial-4 .picto {
height: 100px;
width: 100px;
background-image: url("https://i.postimg.cc/4Y3rypTz/ak-Pest-Control-Logo.jpg");
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
.content_testimonial-4 h1 {
color: #f27935;
}
.content-test h1:first-letter {
text-transform: uppercase;
}
input:checked ~ label {
opacity: 1;
-webkit-animation: all 1s cubic-bezier(0.455, 0.03, 0.515, 0.955);
animation: all 1s cubic-bezier(0.455, 0.03, 0.515, 0.955);
}
input:checked ~ label.label_testimonial-1 {
color: #d64541;
border-right: solid 4px #d64541;
}
input:checked ~ label.label_testimonial-2 {
color: #f5d76e;
border-right: solid 4px #f5d76e;
}
input:checked ~ label.label_testimonial-3 {
color: #00b16a;
border-right: solid 4px #00b16a;
}
input:checked ~ label.label_testimonial-4 {
color: #f27935;
border-right: solid 4px #f27935;
}
label.label_testimonial-1:before {
content: " ";
display: block;
position: absolute;
width: 50px;
height: 50px;
margin-left: 15px;
background-image: url("https://i.postimg.cc/RFBHkG46/diamond-Pest-Logo-small.jpg");
background-position: center;
background-size: 75% 75%;
background-repeat: no-repeat;
border-radius: 50%;
}
label.label_testimonial-2:before {
content: " ";
display: block;
position: absolute;
width: 50px;
height: 50px;
margin-left: 15px;
background-image: url("https://i.postimg.cc/bsqXXKCV/a-Plus-Handyman-Logo.jpg");
background-position: center;
background-size: 75% 75%;
border-radius: 50%;
background-repeat: no-repeat;
}
label.label_testimonial-3:before {
content: " ";
display: block;
position: absolute;
width: 50px;
height: 50px;
margin-left: 15px;
background-image: url("https://i.postimg.cc/zV7sq04z/mod-Movers-Logo.jpg");
background-position: center;
background-size: 75% 75%;
background-repeat: no-repeat;
border-radius: 50%;
}
label.label_testimonial-4:before {
content: " ";
display: block;
position: absolute;
width: 50px;
height: 50px;
margin-left: 15px;
background-image: url("https://i.postimg.cc/4Y3rypTz/ak-Pest-Control-Logo.jpg");
background-position: center;
background-size: 75% 75%;
background-repeat: no-repeat;
border-radius: 50%;
}
label:first-letter {
text-transform: uppercase;
}
.label_testimonial-1:hover {
background-image: -webkit-gradient(
linear,
left top,
right top,
from(#ffffff),
to(#d64541a3)
);
background-image: -webkit-linear-gradient(left, #ffffff, #d64541a3);
background-image: -o-linear-gradient(left, #ffffff, #d64541a3);
background-image: linear-gradient(to right, #ffffff, #d64541a3);
font-size: 1.2rem;
-webkit-transition: font-size 0.5s;
-o-transition: font-size 0.5s;
transition: font-size 0.5s;
}
.label_testimonial-2:hover {
background-image: -webkit-gradient(
linear,
left top,
right top,
from(#ffffff),
to(#f5d76e59)
);
background-image: -webkit-linear-gradient(left, #ffffff, #f5d76e59);
background-image: -o-linear-gradient(left, #ffffff, #f5d76e59);
background-image: linear-gradient(to right, #ffffff, #f5d76e59);
font-size: 1.2rem;
-webkit-transition: font-size 0.5s;
-o-transition: font-size 0.5s;
transition: font-size 0.5s;
}
.label_testimonial-3:hover {
background-image: -webkit-gradient(
linear,
left top,
right top,
from(#ffffff),
to(#00b16aa3)
);
background-image: -webkit-linear-gradient(left, #ffffff, #00b16aa3);
background-image: -o-linear-gradient(left, #ffffff, #00b16aa3);
background-image: linear-gradient(to right, #ffffff, #00b16aa3);
font-size: 1.2rem;
-webkit-transition: font-size 0.5s;
-o-transition: font-size 0.5s;
transition: font-size 0.5s;
}
.label_testimonial-4:hover {
background-image: -webkit-gradient(
linear,
left top,
right top,
from(#ffffff),
to(#f27935a3)
);
background-image: -webkit-linear-gradient(left, #ffffff, #f27935a3);
background-image: -o-linear-gradient(left, #ffffff, #f27935a3);
background-image: linear-gradient(to right, #ffffff, #f27935a3);
font-size: 1.2rem;
-webkit-transition: font-size 0.5s;
-o-transition: font-size 0.5s;
transition: font-size 0.5s;
}
p.testimonialState {
margin-top: -5px;
font-size: 0.8rem;
font-style: italic;
color: #808080d4;
}
p.testimonialFrom {
margin-top: 5px;
font-weight: bold;
color: #33475c;
}
/* ============== End Testimonial Flexbox ============= */
// Makeshift carousel function that gets invoked with the Index to start it off, then the callback increments the index to recursively invoke the same function. Works even in IE11!
var testimonialItems = document.querySelectorAll(".item label");
var timer;
function cycleTestimonials(index) {
timer = setTimeout(function() {
var evt;
if (document.createEvent){
//If browser = IE, then polyfill
evt = document.createEvent('MouseEvent');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
} else {
//If Browser = modern, then create new MouseEvent
evt = new MouseEvent("click", {
view: window,
bubbles: true,
cancelable: true,
clientX: 20
});
}
var ele = "." + testimonialItems[index].className;
var ele2 = document.querySelector(ele)
ele2.dispatchEvent(evt);
index++; // Increment the index
if (index >= testimonialItems.length) {
index = 0; // Set it back to `0` when it reaches `3`
}
cycleTestimonials(index); // recursively call `cycleTestimonials()`
document.querySelector(".testimonials").addEventListener("click", function() {
clearTimeout(timer); //stop the carousel when someone clicks on the div
});
}, 2000); //adjust scroll speed in miliseconds
}
//run the function
cycleTestimonials(0);
Also see: Tab Triggers