I\'m trying to get the glyphicons in my bootstrap site to rotate on hover (in addition to changing color).
Here\'s my attempt: http://jsfiddle.net/young_greedo17/88g5P/<
The font-awesome.css
file sets display: inline
for your selector: [class^="icon-"],
[class*="icon-"]
. You can see this at line 161 of the CSS file:
[class^="icon-"],
[class*=" icon-"] {
display: inline;
width: auto;
height: auto;
line-height: normal;
vertical-align: baseline;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;
margin-top: 0;
}
Therefore you need to set the .widgetbox [class*="icon-"]
to have a property display: block;
http://jsfiddle.net/88g5P/6/
EDIT: after looking up the differences between display:block;
and display:inline-block;
, I came upon this simple visual answer on Stack overflow. Based on this answer, it's probably better to use display:inline-block
In your particular case the issue is that the icons you are using have display: inline-block
, I added display:block
to the custom CSS and it now works.
New Font awesome introduced rotate notation http://fontawesome.io/examples/
//Normal:
<i class="fa fa-shield"></i> normal<br>
//Rotated:
<i class="fa fa-shield fa-rotate-90"></i> fa-rotate-90<br>
<i class="fa fa-shield fa-rotate-180"></i> fa-rotate-180<br>
<i class="fa fa-shield fa-rotate-270"></i> fa-rotate-270<br>
//Flipped
<i class="fa fa-shield fa-flip-horizontal"></i> fa-flip-horizontal<br>
<i class="fa fa-shield fa-flip-vertical"></i> icon-flip-vertical
The problem is that you're trying to transform an inline
element - this isn't possible.
You'll need to change the display value of the glyphicon to inline block.
Here are the details from the CSS Transforms Module:
transformable element
A transformable element is an element in one of these categories:
an element whose layout is governed by the CSS box model which is either a block-level or atomic inline-level element, or whose display property computes to table-row, table-row-group, table-header-group, table-footer-group, table-cell, or table-caption [CSS21]
an element in the SVG namespace and not governed by the CSS box model which has the attributes transform, ‘patternTransform‘ or gradientTransform [SVG11]`
you need to override the icon's display setting, since the rotation won't work on inline elements
.widgetbox [class*="icon-"] {
...
display:block;
}