html - Flag Sprites css library: why it renders badly? -


i want use lot of flags images in website without loading heavy images, found css sprite of flags https://www.flag-sprites.com/ , seems usefull try use , works partially shows ugly img in chrome , firefox:

i have folder index.html , fil library flags.css , flags.png

    <!doctype html> <html> <head>     <meta charset="utf-8" />     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>test sprite flag</title>      <link rel="stylesheet" type="text/css" href="flags.css" /> </head>  <body>      <img class="flag flag-cz" alt=" tchèque" />       <img src="blank.gif" class="flag flag-cz" alt=" tchèque" />           tchèque           <br/>       <img class="flag flag-zanzibar" alt=" zanzibar" />       <img src="blank.gif" class="flag flag-zanzibar" alt=" zanzibar" />       zanzibar    </body>  </html> 

i render in ie but

it renders in google chrome like:

enter image description here

ir renders worse in firefox:

enter image description here

you don't need use <img> tag sprite. you'd better this:

<div class="flag flag-cz"><div> 

and in css file:

.flag{     background-image: url( "adress/the/flag/file.png" );     background-repeat: no-repeat;     width: 32px;        /* width of each country flag */     height: 32px;       /* height of each country flag */ } .flag-cz{     background-position: -32px -32px;       /* position of topmost leftmost pixel of czech republic flag in example */ } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -