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:
ir renders worse in firefox:
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
Post a Comment