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 URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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 id="content">
<div id='popup_content'>
<h1>Custom select</h1>
<fieldset>
<legend>Simple Select</legend>
<form id="form_language">
<label for="language">My favorite language</label>
<div class="select" >
<div class='select_input' id="id_select_input" >
<input type="text" id="language" name="language" readonly="readonly" class='select_text' placeholder="Select a language"/>
<div class='select_icon'>
<span class='caret'></span>
</div>
</div>
<div class='select_box'>
<div class='select_item' data-valeur="JavaScript">
JavaScript
</div>
<div class='select_item'data-valeur="PHP">
PHP
</div>
<div class='select_item' data-valeur="CSS">
CSS
</div>
<div class='select_item' data-valeur="HTML">
HTML
</div>
<div class='select_item' data-valeur="Python">
Python
</div>
<div class='select_item' data-valeur="Ruby">
Ruby
</div>
<div class='select_item' data-valeur="C#">
C#
</div>
<div class='select_item' data-valeur="Java">
Java
</div>
<div class='select_item' data-valeur="C/C++">
C/C++
</div>
<div class='select_item' data-valeur="Bash">
Bash
</div>
</div>
</div>
<input type="button" value="Display">
</form>
</fieldset>
<fieldset>
<legend>Select with clickable optgroup</legend>
<form id="form_framework">
<label for="language">My favorite Framework</label>
<div class="select" >
<div class='select_input' >
<input type="text" id="framework" name="framework" readonly="readonly" class='select_text' placeholder="Select a framework"/>
<div class='select_icon'>
<span class='caret'></span>
</div>
</div>
<div class='select_box'>
<div class='select_group'>
<div class='select_header'>
PHP
<div class='select_icon'>
<span class='caret'></span>
</div>
</div>
<div class='select_item' data-valeur="Symfony">
Symfony
</div>
<div class='select_item' data-valeur="CakePHP">
CakePHP
</div>
<div class='select_item' data-valeur="Laravel">
Laravel
</div>
<div class='select_item' data-valeur="Zend Framework">
Zend Framework
</div>
<div class='select_item' data-valeur="CodeIgniter">
CodeIgniter
</div>
</div>
<div class='select_group'>
<div class='select_header'>
JavaScript
<div class='select_icon'>
<span class='caret'></span>
</div>
</div>
<div class='select_item' data-valeur="JQuery">
JQuery
</div>
<div class='select_item' data-valeur="AngularJS">
AngularJS
</div>
<div class='select_item' data-valeur="VanillaJS">
VanillaJS
</div>
<div class='select_item'data-valeur="React">
React
</div>
</div>
<div class='select_group'>
<div class='select_header'>
Python
<div class='select_icon'>
<span class='caret'></span>
</div>
</div>
<div class='select_item' data-valeur="Django">
Django
</div>
<div class='select_item' data-valeur="Pyramid">
Pyramid
</div>
<div class='select_item' data-valeur="TurboGears">
TurboGears
</div>
</div>
<div class='select_group'>
<div class='select_header'>
CSS
<div class='select_icon'>
<span class='caret'></span>
</div>
</div>
<div class='select_item' data-valeur="Bootstrap">
Bootstrap
</div>
<div class='select_item' data-valeur="Zurb Fundation">
Zurb Fundation
</div>
<div class='select_item' data-valeur="Bulma">
Bulma
</div>
</div>
</div>
</div>
<input type="button" value="Display">
</form>
</fieldset>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
/**
* Custom select file style
* @author Alicia Malacarne
* 2017-2019
* */
body{
font-family:arial;
font-size:18px;
}
#content{
width:70%;
margin:0 auto;
}
fieldset{
margin:4% auto;
width:50%;
border-radius: 5px;
box-shadow: 1px 2px 2px 2px #696969;
border:none;
text-align: center;
}
legend{
padding: 0 5px;
font-weight: bold;
font-size:20px;
background-color: #fff;
}
label, .select, input[type="button"] {
max-width: 90%;
margin: 3%;
}
.select .select_box {
display: none;
flex-direction: column;
flex-wrap: nowrap;
z-index: 99999;
margin-top:0;
position: absolute;
border: 1px solid #1E90FF;
box-shadow:2px 2px 2px #696969;
overflow-x: hidden;
overflow-y: visible;
}
.select .select_input {
display: flex;
flex-wrap:nowrap;
width:100%;
padding:0;
}
.select_input, input[type="button"]{
height:44px;
background-color: #D3D3D3;
border: 1px solid #7F7F7F;
}
.select_icon{
width:9%;
min-width: 7px;
display:flex;
justify-content: center;
align-items:center;
height:100%;
text-align:center;
}
/*down arrow*/
.caret{
border-top:7px solid #111111;
border-left:7px solid transparent;
border-right:7px solid transparent;
border-bottom:7px solid transparent;
display:inline-block;
}
.remove::after{
content:"x";
font-family: verdana;
font-weight:bold;
font-size:20px;
color: #111111;
}
.select_item, .select_header {
display:flex;
align-items: center;
justify-content: space-between;
flex-wrap:nowrap;
width: 99%;
height:44px;
height:2.75em;
padding: 0;
padding-left: 1%;
text-align: left;
}
.select_input *, input[type="button"], .select_header, .select_item {
cursor: pointer;
}
.select_text {
width: 90%;
font-size:16px;
text-align: left;
flex:3;
padding: 0;
padding-left: 5px;
border:none;
}
.select_input .select_text {
color: #C0C0C0;
background-color: #fff;
height: 100%;
}
.select .select_box .select_group {
width: 100%;
}
.select_item {
background-color: #fff;
}
.select_group .select_item {
display:none;
}
.select_header {
background-color: #E5E8E8;
border-bottom: 1px solid #ABB2B9;
z-index:1000;
font-weight: bold;
}
.select_item:nth-child(odd) {
background-color: #DCDCDC;
}
.select_header:hover, .select_header[data-sslist='show'] {
background-color: #7b76ab;
}
.select_item:hover{
background-color:#B0C4DE;
}
/*fond invisible pour fermer la liste*/
#fade_transparant{
display: none; /*--masqué par défaut--*/
position: fixed; left: 0; top: 0;
width: 100%; height: 100%;
opacity: .0;
z-index: 999;
}
/*bug IE6*/
*html #fade_transparant {
position: absolute;
}
*html .select {
position: absolute;
}
@media screen and (max-width:1024px){
#content{
width:100%;
}
.select_text{
overflow: hidden;
}
}
/*adapter les styles des ecrans tablettes et petits ordi*/
@media screen and (min-width:768px) and (max-width:979px){
.select_text, .select_box .select_item, .select_header {
font-size: 16px;
}
.select_input, .select_box .select_item, .select_header {
height:40px;
height:2.5rem;
}
}
/*style ecrans smartphones et petites tabletts*/
@media screen and (max-width:767px){
fieldset{
width:70%;
}
.select_text, .select_box .select_item, .select_header {
font-size: 14px;
}
.select_input, .select_item, .select_header {
height:36px;
height:2.25rem;
}
}
/*smartphones*/
@media screen and (max-width:480px){
fieldset{
width:90%;
}
.select_box{
max-height:90%;
max-width:90%;
margin-top:4% auto;
}
}
@media screen and (max-width: 320px) {
.select .remove {
padding: 3px;
}
}
/**
* @author Alicia Malacarne
* 2017-2019
* Script coded with JQuery framework, take care to call it in your HTML pages
* this function displays a boxlist when the .select_input field is clicked
* Call select() function in your main JQuery script
*/
$(document).ready(function () {
select();
//button click
$('[type=\'button\']').click(function () {
var form = $(this).parent();
var datas = form.serialize();
var txt = 'My favorite ' + datas;
alert(txt);
});
});
function select() {
//display the list
$('.select .select_input').click(function () {
var width = $(this).width();
var box = $(this).parent().find('.select_box');
box.css('display', 'flex').css('width', width + 'px');
resize_boxlist(box);
$('#popup_content').append('<div id=\'fade_transparant\'></div>');
$('#fade_transparant').css({
'filter': 'alpha(opacity=80)'
}).fadeIn();
});
//close list
$('#popup_content').on('click', '#fade_transparant', function () {
close_select();
});
//display sub list
$('.select_box .select_group .select_header').click(function () {
//hide main items list
$('.select_group .select_item').css('display', 'none');
if ($(this).attr('data-sslist') == 'show') {
//remove color selection and close icon
$(this).removeAttr('data-sslist').find('.remove').removeClass('remove').addClass('caret');
//display last header
$('.select_header').css('display', 'flex');
} else {
//remove data-sslist attribute from all headers for getting just one
$('.select_header[data-sslist=\'show\']').removeAttr('data-sslist').find('.remove').removeClass('remove').addClass('caret');
$(this).attr('data-sslist', 'show').find('.caret').removeClass('caret').addClass('remove');
$(this).parent().find('.select_item').css('display', 'flex');
//hide others headers
$('.select_header:not([data-sslist="show"]').css('display', 'none');
}
var box = $(this).parents('.select_box');
resize_boxlist(box);
});
//change dropinput when click on item_list
$('.select_item').click(function () {
var val = $(this).attr('data-valeur');
//modify text display on select_input
$(this).parents('.select').find('.select_input .select_text').val(val);
//close list and fade
close_select();
});
}
/**
* close list and field
*/
function close_select() {
//hide select_box on item click
$('.select_box').css({
'display': 'none',
'top': '',
'max_height': ''
});
//reset display list parameters
$('.select_box').find('.select_header').css('display', 'flex');
$('.select_group').find('.select_item').css('display', 'none');
$('.select_header[data-sslist=\'show\']').removeAttr('data-sslist').find('.remove').removeClass('remove').addClass('caret');
$('#fade_transparant').fadeOut();
$('#fade_transparant').remove();
}
/**
* resize boxlist according to its size and window size
*/
function resize_boxlist(box) {
var boxSize = 0;
var groups=box.find('.select_group');
var nb = groups.length;
if(nb>0){
for (var i = 0; i < nb; i++) {
var elem=$(groups[i]);
boxSize = boxSize + elem.height();
}
}
//check boxlist position
var H = $(window).height();
var h = (boxSize == 0) ? box.height() : boxSize;
var t = box.offset().top;
var T = box.prev().offset().top;
if (h < H) {
if ((h + t) > H) {
if (h < T) {
t = T - h;
} else {
t = (H - h) / 2;
}
}else{
if(t<T){
t=T-h;
}
}
} else {
h = H;
t = 0;
box.css('overflow-y', 'scroll');
}
box.css({
'top': t + 'px',
'max-height': h + 'px'
});
}
Also see: Tab Triggers