Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                - var img = 'https://scriptura.github.io/Images/LotusTest' // 'https://scriptura.github.io/Images/Demo/LotusMacro'
- var alt = 'Lotus'

figure.figure-focus-thumbnail
  picture
    source(media='(min-width: 2000px)' srcset=img + '.jpg, ' + img + '.jpg 2x' sizes='100vw')
    source(media='(min-width: 1500px)' srcset=img + '2000.jpg, ' + img + '.jpg 2x' sizes='100vw')
    source(media='(min-width: 1000px)' srcset=img + '1500.jpg, ' + img + '2000.jpg 2x' sizes='100vw')
    source(media='(min-width: 800px)' srcset=img + '1000.jpg, ' + img + '2000.jpg 2x' sizes='100vw')
    source(media='(min-width: 600px)' srcset=img + '800.jpg, ' + img + '1500.jpg 2x' sizes='100vw')
    source(media='(min-width: 400px)' srcset=img + '600.jpg, ' + img + '1000.jpg 2x' sizes='100vw')
    source(media='(min-width: 300px)' srcset=img + '400.jpg, ' + img + '800.jpg 2x' sizes='100vw')
    source(srcset=img + '300.jpg' sizes='100vw')
    img(src=img + '.jpg' alt=alt)

- var img = 'https://scriptura.github.io/Images/Demo/ColorfulLeaf'
- var alt = 'Colorful leaf'

figure.figure-focus-thumbnail
  picture
    source(media='(min-width: 2000px)' srcset=img + '.jpg, ' + img + '.jpg 2x' sizes='100vw')
    source(media='(min-width: 1500px)' srcset=img + '2000.jpg, ' + img + '.jpg 2x' sizes='100vw')
    source(media='(min-width: 1000px)' srcset=img + '1500.jpg, ' + img + '2000.jpg 2x' sizes='100vw')
    source(media='(min-width: 800px)' srcset=img + '1000.jpg, ' + img + '2000.jpg 2x' sizes='100vw')
    source(media='(min-width: 600px)' srcset=img + '800.jpg, ' + img + '1500.jpg 2x' sizes='100vw')
    source(media='(min-width: 400px)' srcset=img + '600.jpg, ' + img + '1000.jpg 2x' sizes='100vw')
    source(media='(min-width: 300px)' srcset=img + '400.jpg, ' + img + '800.jpg 2x' sizes='100vw')
    source(srcset=img + '300.jpg' sizes='100vw')
    img(src=img + '.jpg' alt=alt)

- var img = 'https://scriptura.github.io/Images/Demo/GrassLeaf'
- var alt = 'Colorful leaf'

figure.figure-focus-thumbnail
  picture
    source(media='(min-width: 2000px)' srcset=img + '.jpg, ' + img + '.jpg 2x' sizes='100vw')
    source(media='(min-width: 1500px)' srcset=img + '2000.jpg, ' + img + '.jpg 2x' sizes='100vw')
    source(media='(min-width: 1000px)' srcset=img + '1500.jpg, ' + img + '2000.jpg 2x' sizes='100vw')
    source(media='(min-width: 800px)' srcset=img + '1000.jpg, ' + img + '2000.jpg 2x' sizes='100vw')
    source(media='(min-width: 600px)' srcset=img + '800.jpg, ' + img + '1500.jpg 2x' sizes='100vw')
    source(media='(min-width: 400px)' srcset=img + '600.jpg, ' + img + '1000.jpg 2x' sizes='100vw')
    source(media='(min-width: 300px)' srcset=img + '400.jpg, ' + img + '800.jpg 2x' sizes='100vw')
    source(srcset=img + '300.jpg' sizes='100vw')
    img(src=img + '.jpg' alt=alt)

              
            
!

CSS

              
                $gutter = 1rem

*
  box-sizing border-box

body
  background-color #333

// @subsection Vector graphics
// -----------------------------------------------------------------------------

svg
  fill currentcolor // Pour les polices d'icônes par défaut.


// @subsection Raster images
// -----------------------------------------------------------------------------

img
  vertical-align middle // Évite un décalage possible de l'élément su//ivant
  //width 100% // @bugfix @todo Depuis l'introduction des attributs 'srcset' et 'sizes' la largeur ne doit plus dépendre de l'image par défaut
  height auto
  max-width 100%
  border-style none // @bugfix Remove the border on images inside links @affected IE 10.


// @subsection Figures
// -----------------------------------------------------------------------------

figure
  margin 0 // @bugfix @affected All browers

[class^=figure]
  //vertical-align middle
  width 100%
  max-width 20rem
  padding .5em
  color #aaa
  background-color #474747
  box-shadow .5rem .5rem 2rem rgba(0, 0, 0, .2)

[class^=figure] figcaption
  padding-top .5em
  text-align center

[class^=figure] + [class^=figure]
  margin-top 2em


// @subsection Thumbnails
// -----------------------------------------------------------------------------

[class*=-thumbnail]
  width 100% // Important à appliquer pour le responsive si le width n'est pas définit préalablement

@media (min-width $sizeXS)

  [class*=-thumbnail]
    max-width 10rem

.js [class*=-focus]
  position relative
  cursor zoom-in
  transition .15s transform

.js [class*=-focus]:focus
.js [class*=-focus]:hover
.js [class*=-focus]:active
.js [class*=-focus]:focus-within
  //z-index 30
  box-shadow .5rem .5rem 2rem rgba(0, 0, 0, .3)
  transform scale(1.01)

.js [class*=-focus]:focus-within
  background-color Orange

[class*=-focus] button
.focus-off button
  position absolute
  z-index 1
  right $gutter
  width 2rem
  height 2rem
  background-color Orange
  border none
  outline none
  cursor zoom-in

[class*=-focus] button
  top $gutter

.focus-off button
  bottom $gutter
  cursor zoom-out
  
.focus-off
  position fixed
  display flex
  align-items center
  //justify-content center // @todo Nécessité de cette règle à évaluer...
  z-index 4001 // @note Doit passer au dessus de tout autre élément, notamment le scroll top
  top 0
  left 0
  bottom 0
  right 0
  //color #aaa
  //background-color #222 // @bugfix @affected Chrome mobile @note box-shadox sur l'image plutôt qu'un background sur le conteneur afin d'éviter un décalage d'environ 1px en bottom.
  cursor zoom-out

.focus-off img
  margin auto
  max-height 100vh
  background-color #000 // @note Pour les .png transparents
  box-shadow 0 0 0 1000rem #222

              
            
!

JS

              
                const jsDetect = (() => { // Uniquement pour le test, dans la vrai vie c'est un html.classList.replace('no-js', 'js')
  const body = document.body
  body.classList.add('js')
})()

const imageFocus = (() => { // Inspiration @see https://scriptura.github.io/Pages/Images.html

  const images = document.querySelectorAll('[class*=-focus]')

  const addButtonEnlarge = (() => {
    for (const image of images) {
      const button = document.createElement('button'),
            text = document.createTextNode('E')
      image.appendChild(button).appendChild(text)
      button.classList.add('icon-enlarge')
    }
  })()

  const clickImage = (() => {
    for (const image of images) image.addEventListener('click', () => {
      cloneImage(image)
      document.body.style.overflow = 'hidden'
    })
  })()

  const cloneImage = image => {
    const imgTag = image.querySelector('img')
    let clone = imgTag.cloneNode(true)
    document.body.appendChild(clone)
    clone = wrapClone(clone)
    clone = clickFocusRemove(image)
  }

  const wrapClone = el => {
    const wrapper = document.createElement('div')
    wrapper.classList.add('focus-off')
    console.log(wrapper)
    el.parentNode.insertBefore(wrapper, el)
    wrapper.appendChild(el)
    addButtonShrink()
  }

  const clickFocusRemove = image => {
    const el = document.querySelector('.focus-off')
          //, button = document.querySelector('.focus-off button')
    el.addEventListener('click', () => {
      el.parentNode.removeChild(el)
      document.body.removeAttribute('style') // document.body.style.overflow = ''
      image.querySelector('button').focus()
    })
  }

  const addButtonShrink = () => {
    const el = document.querySelector('.focus-off'),
          button = document.createElement('button'),
          text = document.createTextNode('R')
    el.appendChild(button).appendChild(text)
    button.classList.add('icon-shrink')
    button.focus()
  }

})()


/* OLD CODE (jQuery):

( function( $ ) {
	$( '[class*="-focus"]' ).prepend( '<span class="icon-enlarge"/>' ); // Ajout d'une icône si classe détectée
	$( document ).on( 'click', '[class*="-focus"]', function( e ) { // @note Event si utilisation sur <a>
		imageFocus = $( this ).find( 'img' ).clone();
		alternativeSource = $( this ).find( 'picture' ).data( 'src' );
		imageFocus
			.removeAttr( 'width' ) // @note La suppression de ces attributs permet le responsive en zoom
			.removeAttr( 'height' ) // @note Idem
			.css( 'display', 'inherit' ) // @bugfix @affected Firefox @note Neutralise une déclaration inligne style 'display:inline' induite (via jQuery ?) sous ce navigateur
			.fadeIn( 300 )
			.appendTo( 'body > footer' )
			.wrap( '<div class="focus-off"><div></div></div>' ) // @bugfix @affected All browsers @note Image en flex item n'a pas son ratio préservé si resize ; une div intermédiaire entre le conteneur .focus-off et l'image corrige ce problème
			.before( '<span class="icon-shrink zoom200"/>' );
		if( ( typeof alternativeSource != 'undefined' ) && ( screen.width < 1500 ) ) { // @note Si petite définition d'écran alors résolution limitée pour l'image
			imageFocus.attr( 'src', alternativeSource );
		}
		$( 'body' ).css( 'overflow', 'hidden' ); // @note Pas de scroll sur la page si photo en focus
		$( document ).find( '.focus-off' ).on( 'click', function( e ) {
			$( '.focus-off' ).fadeOut( 300 );
			setTimeout( function() {
				$( '.focus-off' ).remove();
			}, 300 );
			$( 'body' ).css( 'overflow', 'visible' ); // @note Scroll réactivé
		} );
		e.preventDefault();
	} );
} )( jQuery );
*/

              
            
!
999px

Console