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.
<div class="container">
<!-- TOP TABS -->
<ul id="tabs" class="nav nav-pills nav-justified">
<li class="active">
<a href="#tab1" data-toggle="tab" class="inactiveLink">
Order Summary
<span id="ok-icon" class="glyphicon glyphicon-ok hidden"></span>
</a>
</li>
<li>
<a href="#tab2" data-toggle="tab" class="inactiveLink">Confirmation</a>
</li>
</ul>
<div class="tab-content">
<!-- FIRST TAB -->
<div class="tab-pane active" id="tab1">
<div class="container-fluid">
<h3>Your order:</h3>
<table class="table">
<tbody>
<tr>
<td class="td-padding">360 Pass</td>
<td class="td-padding"><span>100 €</span></td>
<td class="text-center td-padding"><span id="t1_pocet">0</span></td>
<td class="text-right">
<button class="btn" id="t1_minus" onclick="calculate(t1,'minus')">-</button>
<button class="btn" id="t1_plus" onclick="calculate(t1,'plus')">+</button>
</td>
</tr>
<tr>
<td class="td-padding">Summit Pass</td>
<td class="td-padding"><span>350 €</span></td>
<td class="text-center td-padding"><span id="t2_pocet">0</span></td>
<td class="text-right">
<button class="btn" id="t2_minus" onclick="calculate(t2,'minus')">-</button>
<button class="btn" id="t2_plus" onclick="calculate(t2,'plus')">+</button>
</td>
</tr>
<tr>
<td class="td-padding">VIP Summit Pass</td>
<td class="td-padding"><span>800 €</span></td>
<td class="text-center td-padding"><span id="t3_pocet">0</span></td>
<td class="text-right">
<button class="btn" id="t3_minus" onclick="calculate(t3,'minus')">-</button>
<button class="btn" id="t3_plus" onclick="calculate(t3,'plus')">+</button>
</td>
</tr>
</tbody>
</table>
<hr>
<b>Total amount: <span id="amount"></span> €</b>
<hr>
<div class="text-right">
<button id="continue" class="btn btn-success" disabled> CONTINUE </button>
</div>
</div> <!-- end container fluid -->
</div> <!-- end Tab1 content -->
<div class="tab-pane" id="tab2">
<div class="container-fluid">
<h3>Confirm your order:</h3>
<hr>
<div class="row">
<label for="name" class="col-sm-4 p-top text-right">Name</label>
<div class="col-sm-6">
<input type="text" class="form-control" name="name" placeholder="Full name" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<label for="email" class="col-sm-4 p-top text-right">Email</label>
<div class="col-sm-6">
<input type="email" class="form-control" name="email" placeholder="[email protected]" required>
<div class="help-block with-errors"></div>
</div>
</div>
<div class="row">
<label for="payment" class="col-sm-4 p-top text-right">Payment Method</label>
<div class="col-sm-4">
<select class="form-control" name="payment">
<option value="Invoice">Invoice</option>
<option value="Credit card">Credit card</option>
</select>
</div>
</div>
<div class="form-group">
<div id="listed_t1" class="hidden listed paddingLF"><h4>360 pass tickets:</h4></div>
<div id="listed_t2" class="hidden listed paddingLF"><h4>Summit pass tickets:</h4></div>
<div id="listed_t3" class="hidden listed paddingLF"><h4>VIP pass tickets:</h4></div>
</div>
<!-- Tady jsou skryte inputy -->
<div class="form-group hidden">
<input id="total_amount" type="number" name="total_amount" value="0">
<input id="t1_amount" type="number" name="t1_amount" value="0">
<input id="t2_amount" type="number" name="t2_amount" value="0">
<input id="t3_amount" type="number" name="t3_amount" value="0">
</div>
<hr>
<div class="row paddingLF">
<div class="text-left buttons-wrapper pull-left">
<button id="back" type="button" class="btn btn-warning">BACK</button>
</div>
<div class="text-right buttons-wrapper pull-right">
<button id="submit_details" type="submit" class="btn btn-success">SEND</button>
</div>
</div>
</div> <!-- end container-fluid -->
</div> <!-- end tab-content -->
</div><!-- end container -->
.btn:focus {
outline: none;
}
.hidden {
display: none;
}
.listed {
padding-top: 10px;
padding-bottom: 10px;
}
.p-top {
padding-top: 7px;
}
.td-padding {
padding-top: 15px !important;
}
.container {
padding-top: 10px;
padding-bottom: 10px;
min-width: 480px;
max-width: 768px;
}
.container-fluid {
padding-bottom: 10px;
margin-top: 1px;
border: 1px solid #ccc;
border-radius: 5px;
}
.paddingLF {
padding-left: 15px;
padding-right: 15px;
}
.inactiveLink {
pointer-events: none;
cursor: default;
}
.buttons-wrapper {
display: inline-block;
}
/* when jQuery laods */
$(document).ready(function() {
/* click on back button - will do reset and removal of previously appended children */
$('#back').on('click', function() {
$('li.active').filter('.active').prev('li').find('a[data-toggle="tab"]').tab('show');
$('li').find('a[data-toggle="tab"]').removeClass('btn-success');
$('#ok-icon').addClass('hidden');
total_tickets = 0;
$('#listed_t1').addClass('hidden').children().not('h4').remove();
$('#listed_t2').addClass('hidden').children().not('h4').remove();
$('#listed_t3').addClass('hidden').children().not('h4').remove();
render();
});
/* click on continue button */
$('#continue').on('click', function() {
if (total_tickets > 0) {
$('li.active').filter('.active').next('li').find('a[data-toggle="tab"]').tab('show');
$('li').find('a[data-toggle="tab"]').addClass('btn-success');
$('#ok-icon').removeClass('hidden');
addTicketList(t1);
addTicketList(t2);
addTicketList(t3);
}
});
render();
});
/* VARIABLES */
var total = 0; // total amount to be paid
var total_tickets = 0; // total amount of tickets
var t1 = { id: 't1', pocet: 0, hodnota: 100 }; // ticket 1st category
var t2 = { id: 't2', pocet: 0, hodnota: 350 }; // ticket 2nd category
var t3 = { id: 't3', pocet: 0, hodnota: 800 }; // ticket 3rd category
/* perform either adding or substracting on a provided object */
calculate = function(object, action) {
if (action === 'plus') {
total += object.hodnota;
object.pocet++;
} else if ((action === 'minus') && (object.pocet > 0)) {
total -= object.hodnota;
object.pocet--;
}
render();
}
/* recalculate and display numbers + assigning hidden inputs */
render = function() {
total_tickets = t1.pocet + t2.pocet + t3.pocet;
$('#amount').html(total.toFixed(0));
$('#t1_pocet').html(t1.pocet); $('#t2_pocet').html(t2.pocet); $('#t3_pocet').html(t3.pocet);
/* assigning hidden inputs */
$('#total_amount').html(total.toFixed(0));
$('#t1_amount').html(t1.pocet); $('#t2_amount').html(t2.pocet); $('#t3_amount').html(t3.pocet);
if (total_tickets > 0) {
$('#continue').prop('disabled', false);
} else {
$('#continue').prop('disabled', true);
}
}
/* add a list of tickets if multiple tickets are selected, argument is a ticket category */
addTicketList = function(objekt) {
if (objekt.pocet > 1 || total_tickets > 1) {
for (var i = 0; i < objekt.pocet; i++) {
$('#listed_' + objekt.id).removeClass('hidden').append(insert(i+1));
}
}
}
/* insert a row if multiple ticket are selected, argument passed is a ticket count (for that section) */
var insert = function(num) {
return (
"<div class='row'>"+
"<div class='col-xs-1'><label for='row' class='p-top'><span class='ticket_span'>"+ num +"#</span></label></div>"+
"<div class='col-xs-5'><input type='text' class='form-control' name='names[]' placeholder='Full name' required></div>"+
"<div class='col-xs-6'><input type='email' class='form-control' name='emails[]' placeholder='[email protected]' required></div>"+
"</div>");
}
Also see: Tab Triggers