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. You can use the CSS from another Pen by using it's URL and the proper URL extention.
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 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.
<!--
Voici nos thumbnails.
L'attribut data-img nous permet de definir l'adresse de l'image, qu'il /
ne faut pas confondre avec src, qui est l'adresse de la miniature.
La div .thumbnail ne nous sert que d'un point de vue CSS.
-->
<div class="thumbnail">
<img data-img="http://www.richardhellergallery.com/dynamic/images/detail/Corey_Arnold_The_North_Sea_2011_1927_412.jpg" src="http://www.richardhellergallery.com/dynamic/images/detail/Corey_Arnold_The_North_Sea_2011_1927_412.jpg" alt="La mer" />
</div>
<div class="thumbnail">
<img data-img="http://www.earthtimes.org/newsimage/plenty-fish-mediterranean-sea-not-anymore_214.jpg" src="http://www.earthtimes.org/newsimage/plenty-fish-mediterranean-sea-not-anymore_214.jpg" alt="Des poissons"/>
</div>
<div class="thumbnail">
<img data-img="http://coastalcare.org/wp-content/images/learn/flora-and-fauna/seagull.jpg" src="http://coastalcare.org/wp-content/images/learn/flora-and-fauna/thumbs/seagull.jpg" alt="Une mouette !"/>
</div>
<!-- Je vous mets ici un exemple de la light box telle quelle apparaîtra une fois ouverte -->
<!--<div id="blackout">
<div class="title">La mer<div>
<img src="http://wallpapers.wallbase.cc/rozne/wallpaper-1324799.jpg" />
</div>-->
@import compass
// Cette partie du CSS ne sert que pour mettre en forme la galerie.
.thumbnail
width: 300px
height: 300px
float: left
margin: 5px
position: relative
overflow: hidden
.thumbnail img
height: 100%
// Cette petite ligne permet de choisir le curseur affiche lors du survol de l'élément.
cursor: pointer
// Nous voila dans le CSS de la lightbox
#blackout
// Ces 6 lignes nous assurent un affichage en plein-ecran, au dessus du reste
position: fixed
top: 0
left: 0
width: 100%
height: 100%
z-index: 10
// Si vous avez des envies de transparences, faites le avec la couleur
// du fond, et pas avec une opacity: 0.9 sur la boite.
// De cette facon, vos images resteront opaques.
background: rgba(0,0,0,0.9)
text-align: center
// Cette ligne nous permet de mettre un curseur en croix, pour
// simplifier la comprehension.
cursor: url('http://www.rouvre.com/themes/default/images/cursor-close.png'), crosshair
// Ceci est notre élément titre. Designez comme vous l'entendez
.title
width: 100%
height: 20px
background-color: rgba(0,0,0,0.4)
text-align: center
color: white
display: block
position: absolute
top: 10px
left: 20px
// Notre image
img
max-width: 100%
max-height: 100%
// Nous voila dans le JS, que je vais essayer de le garder le plus clair et concis possible.
$(function(){
// C'est ici que nous definissons les images qui doivent ouvrir une lightbox au click.
// Pour nous, toutes les images dans les élément ovec la classe "thumbnail"
$(".thumbnail img").click(function(){
// Récupérationdu body, pour la suite
var $body = $('body');
// L'image qui as ete ouverte
$thumbnail = $(this);
// Nous créons ici nos elements
var $blackout = $("<div id='blackout'>").css("display", "none");
// La source de notre image provient bien du "data-img" de la thumbnail
var $img = $("<img>").attr("src", $thumbnail.data("img"));
$blackout.append($img);
// Nous créons le titre si l'attribut alt existe
if($(this).attr("alt")){
var $title = $("<div class='title'>"+ $thumbnail.attr("alt") +"</div>");
$blackout.append($title);
}
// Ce block ne s'execute pas maintenant, mais au prochain click sur notre "blackout". Il se lit comme suit :
// Au clic sur le fond...
$blackout.click(function(){
// On fait disparaitre progressivement la lightbox...
$blackout.fadeOut(function(){
// Puis on la supprime.
$blackout.remove();
})
});
// On ajoute notre lightbox au body.
$body.append($blackout);
//Et enfin nous la faisons apparaitre progressivement.
$blackout.fadeIn();
// Ces trois petites lignes permettent de centrer l'image en hauteur
if($img.height() < $blackout.height()){
$img.css("marginTop", ($blackout.height() - $img.height()) / 2);
}
})
})
Also see: Tab Triggers