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 id="photo-gallery">
<div class="project">
<div class="frame">
<div class="frame-inside">
<div class="border-frame style1"></div>
<div class="container-image"><img src="http://pixel-salad.com/website/photo_gallery/img/landscape1.jpg"></div>
</div>
</div>
<div class="details">
<div class="title">Some plants</div>
<div class="subtitle">This is a subtitle</div>
</div>
<div class="expand">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec magna purus, bibendum maximus elit at, luctus ultricies purus. Vestibulum vitae nisl mi. Sed nec purus orci.</p>
<p>Nam risus orci, efficitur in pellentesque aliquet, efficitur eget orci. Pellentesque suscipit tellus a massa auctor laoreet. Quisque rutrum faucibus leo, a mattis tellus posuere a. Donec vel suscipit magna, sagittis scelerisque orci.</p>
<p class="extra-infos">2009 - India</p>
</div>
</div>
<div class="project">
<div class="frame">
<div class="frame-inside">
<div class="border-frame style2"></div>
<div class="container-image"><img src="http://pixel-salad.com/website/photo_gallery/img/portrait1.jpg"></div>
</div>
</div>
<div class="details">
<div class="title">Starry night</div>
<div class="subtitle">This is a subtitle</div>
</div>
<div class="expand">
<p>Pellentesque commodo elementum ullamcorper. Nullam ut finibus massa, eu accumsan leo. Duis eget scelerisque urna, ac molestie lorem. Sed quis egestas mauris. Etiam porta est tellus, non vehicula elit consequat at.</p>
<p>Phasellus quis varius est. Curabitur viverra nisi quis malesuada luctus. Sed imperdiet elementum tellus, ut scelerisque est sodales ac. Ut commodo placerat nisl, eget hendrerit dolor.</p>
<p class="extra-infos">2012 - Croatia</p>
</div>
</div>
<div class="project">
<div class="frame">
<div class="frame-inside">
<div class="border-frame style3"></div>
<div class="container-image"><img src="http://pixel-salad.com/website/photo_gallery/img/landscape2.jpg"></div>
</div>
</div>
<div class="details">
<div class="title">aww yisss pollen</div>
<div class="subtitle">This is a subtitle</div>
</div>
<div class="expand">
<p>Sed feugiat in augue eu cursus. Integer euismod porta mi ac suscipit. Fusce eleifend ultricies nibh id vestibulum.</p>
<p>Vestibulum elementum cursus nisi sit amet blandit. Praesent convallis, quam eu ultricies bibendum, augue nisl lacinia lacus, sit amet euismod dui nisi eget purus. Nulla ut nisl volutpat, laoreet diam interdum, lacinia felis. Curabitur accumsan ultrices magna</p>
<p class="extra-infos">2013 - California</p>
</div>
</div>
<div class="project">
<div class="frame">
<div class="frame-inside">
<div class="border-frame style4"></div>
<div class="container-image"><img src="http://pixel-salad.com/website/photo_gallery/img/portrait2.jpg"></div>
</div>
</div>
<div class="details">
<div class="title">Flower essence</div>
<div class="subtitle">This is a subtitle</div>
</div>
<div class="expand">
<p>nec imperdiet ipsum luctus vel. Cras neque quam, posuere sed suscipit pharetra, ultricies sed sem. Sed mattis tristique condimentum. Mauris a orci nec sem pretium porttitor. Nam viverra mi nec mauris molestie accumsan.</p>
<p class="extra-infos">2014 - France</p>
</div>
</div>
<div class="project">
<div class="frame">
<div class="frame-inside">
<div class="border-frame style5"></div>
<div class="container-image"><img src="http://pixel-salad.com/website/photo_gallery/img/landscape3.jpg"></div>
</div>
</div>
<div class="details">
<div class="title">No time to explain, jump in!</div>
<div class="subtitle">This is a subtitle</div>
</div>
<div class="expand">
<p>In hac habitasse platea dictumst. Proin viverra enim nulla, id auctor leo vehicula quis. Nam hendrerit quam et ultricies vehicula. Donec sed risus ligula. Curabitur ac metus odio. Cras vehicula tempor elit nec venenatis. Donec euismod fringilla aliquet. Cras non lacus velit.</p>
<p class="extra-infos">2015 - UK</p>
</div>
</div>
<div class="project">
<div class="frame">
<div class="frame-inside">
<div class="border-frame style6"></div>
<div class="container-image"><img src="http://pixel-salad.com/website/photo_gallery/img/portrait3.jpg"></div>
</div>
</div>
<div class="details">
<div class="title">Quiet place</div>
<div class="subtitle">This is a subtitle</div>
</div>
<div class="expand">
<p>Suspendisse molestie, dolor at maximus sagittis, magna diam convallis nunc, sit amet iaculis ipsum arcu a nisi. Vestibulum pellentesque in lorem non hendrerit. Mauris in vestibulum orci. Sed tellus neque, cursus a eros nec, tempor sodales ligula.</p>
<p class="extra-infos">2016 - Sweden</p>
</div>
</div>
</div>
@import url('https://fonts.googleapis.com/css?family=Open+Sans|Open+Sans+Condensed:700');
@media (max-height:500px) {
#photo-gallery{
padding: 30px 100px 80px 30px;
}
.frame-inside{
padding: 35px;
}
}
@media (min-height:501px) {
#photo-gallery{
padding: 100px;
}
.frame-inside{
padding: 60px;
}
}
body{
margin: 0;
padding: 0;
color: #333;
font-family: 'Open Sans', sans-serif;
text-rendering: optimizeLegibility;
overflow-y: hidden;
background: url("http://pixel-salad.com/website/photo_gallery/img/white-wall.jpg");
background-repeat: repeat;
}
body::after{
content: '';
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.15));
}
#photo-gallery{
position: relative;
white-space: nowrap;
height: 100vh;
width: 100%;
box-sizing: border-box;
}
.project{
position: relative;
display: inline-block;
margin: 0;
padding: 0;
vertical-align: middle;
height: 100%;
width: auto;
width: initial;
min-height: 200px;
max-height: 600px;
margin-right:100px;
box-shadow:
inset 1px 1px 3px rgba(0,0,0,.3),
1px 1px 2px rgba(0,0,0,.2),
40px 35px 70px -10px rgba(0,0,0,.5),
-20px -20px 100px -10px rgba(255,255,255,.8);
transition: all .3s ease-in-out;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
cursor: pointer;
}
.frame{
position: relative;
height: 100%;
width: auto;
width: initial;
margin: 0;
overflow: hidden;
}
.frame::after{
/* HIGHLIGHT ON TOP OF FRAME */
content: '';
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
height: 100%;
width: 100%;
box-shadow: inset 0px 3px 0px rgba(255,255,255,0.5);
}
.frame-inside{
position: relative;
height: 100%;
width: auto;
margin: 0;
background-color: #fff;
box-sizing: border-box;
transition: all .3s ease-in-out;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-webkit-transform-origin: center center;
-moz-transform-origin: center center;
-o-transform-origin: center center;
transform-origin: center center;
}
.container-image{
position: relative;
height: 100%;
width: auto;
width: initial;
}
.container-image img{
position: relative;
height: 100%;
width: auto;
}
.border-frame{
position: absolute;
margin: 0;
padding: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
box-sizing: border-box;
box-shadow: inset 0px 10px 30px rgba(0,0,0,0.3);
overflow: hidden;
}
.border-frame::after{
/* GLASS REFLECTION */
content: '';
position: absolute;
margin: 0;
padding: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(255,255,255,0.2), rgba(255,255,255,0));
-webkit-transform: translateX(50%) skewX(-20deg);
-moz-transform: translateX(50%) skewX(-20deg);
-o-transform: translateX(50%) skewX(-20deg);
transform: translateX(50%) skewX(-20deg);
transition: opacity .3s ease-in-out;
-webkit-transition: opacity .3s ease-in-out;
-moz-transition: opacity .3s ease-in-out;
}
.details{
position: relative;
margin: 0;
padding: 0;
top: 20px;
opacity: 0;
transition: all .3s ease-in-out;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
pointer-events: none;
}
.details .title{
font-family: 'Open Sans Condensed', sans-serif;
text-transform: uppercase;
font-size: 20px;
color: #333;
}
.details .subtitle{
font-size: 15px;
color: #333;
}
.expand{
position: absolute;
font-size: 15px;
color: #333;
right: -425px;
top: 0;
width: 400px;
height: 100%;
white-space: normal;
text-align: justify;
transition: all .3s ease-in-out;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
pointer-events: none;
display: none;
opacity: 0;
}
.expand p{
margin-top: 20px;
}
.expand .extra-infos{
font-family: 'Open Sans Condensed', sans-serif;
text-transform: uppercase;
text-align: right;
font-size: 14px;
}
.frame:hover .frame-inside{
-webkit-transform: scale(2.2);
-moz-transform: scale(2.2);
-o--transform: scale(2.2);
transform: scale(2.2);
}
.active:hover::after{
opacity: 0.5;
}
.frame:hover .border-frame::after{
opacity: 0;
}
.active{
margin-right: 500px;
}
.active::after{
content: 'x';
position: absolute;
font-size: 50px;
text-align: center;
color: #fff;
top: 0;
left: 0;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: #000;
opacity: 0;
display:flex;
align-items: center;
justify-content: center;
transition: opacity .3s ease-in-out;
-webkit-transition: opacity .3s ease-in-out;
-moz-transition: opacity .3s ease-in-out;
}
.active .details, .active .expand{
display: block;
opacity: 1;
}
.active .border-frame::after{
opacity: 0;
}
/* FRAME CUSTOMIZATION */
.style1{
border: solid 20px #333;
}
.style2{
border: solid 10px #fff;
}
.style3{
border: solid 15px #a52f2f;
}
.style4{
border: solid 25px #eee;
}
.style5{
border: solid 8px #222;
}
.style6{
border: solid 35px #ffffff;
}
$(function(){
var i = 0;
var myResizeTimer = null;
function scrollHorizontally(e) {
e = window.event || e;
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
document.documentElement.scrollLeft -= (delta*40);
document.body.scrollLeft -= (delta*40);
e.preventDefault();
}
if (window.addEventListener) {
// IE9, Chrome, Safari, Opera
window.addEventListener("mousewheel", scrollHorizontally, false);
// Firefox
window.addEventListener("DOMMouseScroll", scrollHorizontally, false);
} else {
// IE 6/7/8
window.attachEvent("onmousewheel", scrollHorizontally);
}
$(".project").click(function(){
var otherActive = null;
//FIND OTHER ACTIVE ELEMENT AND DESACTIVATE IT
if( $(".active").length>0 ) otherActive = $(".active");
var tempMargin = 0;
if( (otherActive != null)&&(otherActive.index() !== $(this).index()) ){
if((otherActive.index() < $(this).index())) tempMargin = 450;
$(otherActive).toggleClass("active");
}
//ACTIVATE NEW ELEMENT
if( $(this).hasClass("active") ==false ){
var targetPosition = $(this).position().left - 40 - tempMargin;
$(window).scrollTo(targetPosition, 500, {axis:'x'});
}
$(this).toggleClass("active");
})
window.onresize = function(){
if(myResizeTimer != null) clearTimeout(myResizeTimer);
myResizeTimer = setTimeout(function(){
window.history.go(0);
}, 100);
}
});
Also see: Tab Triggers