Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ 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

Auto Save

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

              
                <h1>
    Les sprites CSS. Découvrez 4 techniques
</h1>

<p>
    Les sprites CSS sont utilisés pour économiser de la bande passante en réduisant le nombre de requêtes HTTP. L'astuce consiste à regrouper les différentes image en un seul et même fichier. Certes ce dernier est légèrement plus lourd, mais téléchargé qu’une seule fois. La solution la plus souvent utilisée pour les intégrer consiste à appeler l’image en background. Mais saviez-vous qu’il existe d’autres méthodes pour utiliser les sprites CSS ?
</p>

<p>
    L'image regroupant les sprites :
</p>

<p>
    <img src="https://genesis-technology.fr/codepen/sprites-css/sprite-css-icons-final-min.png" alt="Sprites CSS">
</p>

<p>
    Les 4 techniques pour intégrer des sprites css :
</p>

<div class="sprite bg-sprite"> 
    <!--RSS icon-->
</div>

<div class="sprite object-position-sprite">
    <img src="https://genesis-technology.fr/codepen/sprites-css/sprite-css-icons-final-min.png" alt="Facebook icon">
</div>

<div class="sprite margin-sprite">
    <img src="https://genesis-technology.fr/codepen/sprites-css/sprite-css-icons-final-min.png" alt="SLinkedin icon">
</div>

<img class="sprite object-fit-sprite" src="https://genesis-technology.fr/codepen/sprites-css/sprite-css-icons-final-min.png" alt="Pinterest icon">

<p>
    Pour en savoir plus sur les sprites lisez l'article <a href="https://genesis-technology.fr/les-sprites-css-quatre-methodes-pour-les-mettre-en-place/" target="_blank">Les sprites CSS. Quatre méthodes pour les mettre en place</a>
</p>


              
            
!

CSS

              
                *{
    box-sizing: border-box;
}

body{
    font-family: arial, sans-serif;
}

div.sprite {
    display: inline-block;
    margin-right: 5px;
}

.bg-sprite{
    background-image: url(https://genesis-technology.fr/codepen/sprites-css/sprite-css-icons-final-min.png);
    background-repeat: no-repeat;
    background-position: -57px 0;
    height: 49px;    
    transition: all 1s ease 0s;
    width: 49px;
    filter: drop-shadow(2px 2px 2px #000);
}

.bg-sprite:hover{
    background-position: -57px -64px;
}

.object-position-sprite{
    height: 49px;
    width: 49px;
    overflow: hidden;
    filter: drop-shadow(2px 2px 2px #000);
}

.object-position-sprite img{
    transition: object-position 1s ease 0s;
}

.object-position-sprite:hover img{
    object-position: 0 -64px;
}

.margin-sprite{
    height: 49px;
    width: 49px;
    overflow: hidden;
    filter: drop-shadow(2px 2px 2px #000);
}

.margin-sprite img{
    /* margin-top: 0px; */
    margin-left: -114px;
    transition: all 1s ease 0s;
}

.margin-sprite:hover img{
    margin-top: -64px;
}

.object-fit-sprite{
    filter: drop-shadow(2px 2px 2px #000);
    object-fit: none;
    object-position: -171px 0;
    height: 49px;
    transition: all 1s ease 0s;
    width:49px
}

.object-fit-sprite:hover{
    object-position: -171px -64px;
}
              
            
!

JS

              
                
              
            
!
999px

Console