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.
div(data-scroll)
div.smooth-scroll(data-scroll-content)
header.header.e-rel.e-wvw.e-hvh.e-flex.e-black.e-hidden
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole04.jpg", alt="").e-wp.e-hp.e-abs.e-img-fit
h1.t-white THIS IS HEADER
section.before-footer.e-wvw.e-hvh
.img
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole04.jpg", alt="")
section.e-wvw.e-hvh.master
.img.e-wp.e-hp
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole03.jpg", alt="").e-wp.e-hp.e-img-fit
.trg-sticky
section.before-footer.e-wvw.e-hvh.sticked
.img
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole03.jpg", alt="")
section.e-wvw.e-hvh.master
.img.e-wp.e-hp
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole02.jpg", alt="").e-wp.e-hp.e-img-fit
.trg-sticky
section.before-footer.e-wvw.e-hvh.sticked
.img
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole02.jpg", alt="")
section.e-wvw.e-hvh.master
.img.e-wp.e-hp
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole05.jpg", alt="").e-wp.e-hp.e-img-fit
.trg-sticky
section.before-footer.e-wvw.e-hvh.sticked
.img
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole05.jpg", alt="")
section.before-footer.e-wvw.e-hvh.super-before
.img
img(src="https://raw.githubusercontent.com/Efetivos/gallery/master/nicole/slider-nicole04.jpg", alt="")
footer.footer.e-wvw.e-hvh
.footer__hold
.links
each list, index in ['About us', 'Portfolio', 'Services', 'Works', 'Home', 'Contact']
h2=list
.infos
p 19144, Cruickshank Avenue<br> Baie-d’Urfé (Québec)<br> H9X 3P1 Canada
.infos
p 19144, Cruickshank Avenue<br> Baie-d’Urfé (Québec)<br> H9X 3P1 Canada
@import url('https://fonts.googleapis.com/css?family=Poppins:200&display=swap')
body
background: #000
font-family: "Poppins",sans-serif
//text-transform: uppercase
h1
font-size: 9vw
z-index: 1
section
width: 100vw
height: 100vh
position: relative
background: #000
.before-footer
display: flex
align-items: center
justify-content: center
.img
width: 55vw
height: 55vh
position: relative
img
width: 100%
height: 100%
object-fit: cover
.footer
cursor: pointer
background: #dcc8ac
width: 100vw
height: 100vh
display: flex
align-items: center
justify-content: center
&__hold
width: 80vw
display: flex
justify-content: space-between
align-items: flex-end
h2
font-size: 3.5vw
padding: 10px 0
p
line-height: 25px
.master
position: relative
z-index: 1
.sticked
transform: translateY(-100vh)
.super-before
position: relative
z-index: 2
console.clear();
let h = window.innerHeight
let w = window.innerWidth
//
// Pin Works
//-------------------------------------------------
let $header = $('header.header')
let $footer = $('footer.footer')
let $trgSticky = document.querySelectorAll('.trg-sticky')
let stickies = []
$trgSticky.forEach(function(item){
stickies.push(item)
})
function pinned(scrolled){
//? - ========================= FAKE STICKY ========================= -//
//? - ========================= FAKE STICKY ========================= -//
$trgSticky.forEach(function(item, index){
let itemPosition = item.getBoundingClientRect().top
let itemBottom = item.getBoundingClientRect().bottom
let fakeOffset = ((scrolled * -1) - (itemPosition - window.innerHeight)) * - 1
if(itemPosition < (window.innerHeight * 1.1) && itemBottom > 0) {
let percentageDuration = (scrolled - fakeOffset) / ((fakeOffset + (window.innerHeight * 1.5)) - fakeOffset)
gsap.set($('.sticked').eq(index), { yPercent: (150 * percentageDuration)})
}
})
//______________ HEADER
if(scrolled < h) {
let percentHeader = scrolled / h
gsap.set($header, { yPercent: (40* percentHeader)})
gsap.set($header.find('img'), { scale: 1 + ((1.03 * percentHeader) / 3)})
}
//______________ FOOTER PARALLAX
let sizeDocument = $('[data-scroll-content]').height()
//console.log(sizeDocument - (h * 2))
if(scrolled > sizeDocument - (h * 2)) {
let percentageFromTop = ((sizeDocument - h) - scrolled) / h
gsap.set($footer, { y: - (h * percentageFromTop)})
gsap.set($footer, { yPercent: (30 * percentageFromTop)})
}
} //close pinned
function smoothScroll() {
if($(window).width() > 80) {
const math = {
lerp: (a, b, n) => {
return (1 - n) * a + n * b
},
norm: (value, min, max) => {
return (value - min) / (max - min)
}
}
const config = {
height: window.innerHeight,
width: window.innerWidth
}
class Smooth {
constructor() {
this.bindMethods()
this.data = {
ease: 0.085,
current: 0,
last: 0
}
this.dom = {
el: document.querySelector('[data-scroll]'),
content: document.querySelector('[data-scroll-content]')
}
this.rAF = null
this.init()
}
bindMethods() {
['scroll', 'run', 'resize']
.forEach((fn) => this[fn] = this[fn].bind(this))
}
setStyles() {
this.dom.el.style.position = 'fixed';
this.dom.el.style.top = 0;
this.dom.el.style.left = 0;
this.dom.el.style.height = '100%'
this.dom.el.style.width = '100%'
this.dom.el.style.overflow = 'hidden'
}
setHeight() {
document.body.style.height = `${this.dom.content.offsetHeight}px`
}
resize() {
this.setHeight()
this.scroll()
}
scroll() {
this.data.current = window.scrollY
}
run() {
this.data.last = math.lerp(this.data.last, this.data.current, this.data.ease)
this.data.last = Math.floor(this.data.last * 100) / 100
const diff = this.data.current - this.data.last
const acc = diff / config.width
const velo =+ acc
//console.log(velo)
this.dom.content.style.transform = `translate3d(0, -${this.data.last.toFixed(0)}px, 0) `
//call pinned
pinned(this.data.last)
this.requestAnimationFrame()
}
on(requestAnimationFrame = true) {
this.setStyles()
this.setHeight()
this.addEvents()
requestAnimationFrame && this.requestAnimationFrame()
}
off(cancelAnimationFrame = true) {
cancelAnimationFrame && this.cancelAnimationFrame()
this.removeEvents()
}
requestAnimationFrame() {
this.rAF = requestAnimationFrame(this.run)
}
cancelAnimationFrame() {
cancelAnimationFrame(this.rAF)
}
destroy() {
document.body.style.height = ''
this.data = null
this.removeEvents()
this.cancelAnimationFrame()
}
resize() {
this.setHeight()
}
addEvents() {
window.addEventListener('resize', this.resize, { passive: true })
window.addEventListener('scroll', this.scroll, { passive: true })
}
removeEvents() {
window.removeEventListener('resize', this.resize, { passive: true })
window.removeEventListener('scroll', this.scroll, { passive: true })
}
init() {
this.on()
}
}
const smooth = new Smooth()
}
}//close menu
smoothScroll()
Also see: Tab Triggers