What is the CSS that makes font-awesome's stack icons work? -


can explain css behind font awesome's stack icon? i'm trying create own custom stack icon font, fail them stack way font-awesome manage it.

i'm not sure specific css manage make stack "happen".

(as far know, not duplicate: there lot of questions how use font-awesome stack icons, none behind mechanism of it.)

the icons contained in fontawesome font. magic in number of helper css classes let select icon character , let position these icons easily. each class reponsible piece of functionality, give modular build-up of icon.

stacking when stacking 2 icons fontawesome, need span class fa-stack. span adds position: relative, allows position 2 stacked icons absolutely , doing so, making them overlap.

the size set 2em, because background (or overlay) twice size compared normal icon. givin exact width makes sure enough space claimed icons, smaller icon can centered horizontally.

the icons inside span class fa-stack-1x or fa-stack-2x dictates size , position within parent span.

so, summing notable classes (for icons , stacking):

  • fa set right font. makes icon out of element.
  • fa-twitter, , many others let select character. character added in css in content of ::before pseudo-element.
  • fa-stack defines container contain stacked icons. adds position: relative, can absolutely position icons in it.
  • fa-stack-2x makes icon twice size , positions @ 0,0 in parent container. used background or overlay icons.
  • fa-stack-1x uses 100% of width of parent , centers icon in it. used smaller image icon used background/overlay icon.

other features, rotation, work in similar way adding right class.


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 -