Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate an ionicon on the page

I want to display directions with an arrow and was thinking to use the standard ionic arrow for the direction. Can I rotate the up arrow into any direction somehow?

ion-arrow-up-a

Here is an attempt from the comments below

<i class="icon ion-arrow-up-a" rotate degrees="90"></i>


angular.module('app.customDirectives', []).directive('rotate', function() {
      return {
            link: function(scope, element, attrs) {
                // watch the degrees attribute, and update the UI when it changes
                scope.$watch(attrs.degrees, function(rotateDegrees) {
//                  console.log(rotateDegrees);
                    //transform the css to rotate based on the new rotateDegrees
                    element.css({
                        '-moz-transform': 'rotate(' + rotateDegrees + 'deg)',
                        '-webkit-transform': 'rotate(' + rotateDegrees + 'deg)',
                        '-o-transform': 'rotate(' + rotateDegrees + 'deg)',
                        '-ms-transform': 'rotate(' + rotateDegrees + 'deg)'
                    });
                });
            }
    }
});
like image 567
El Dude Avatar asked Jun 16 '15 00:06

El Dude


People also ask

How do you rotate an ion-icon?

css({ '-moz-transform': 'rotate(' + rotateDegrees + 'deg)', '-webkit-transform': 'rotate(' + rotateDegrees + 'deg)', '-o-transform': 'rotate(' + rotateDegrees + 'deg)', '-ms-transform': 'rotate(' + rotateDegrees + 'deg)' }); }); } } }); javascript. ionic-framework. ionicons.

How do I resize an ion-icon?

Size. To specify the icon size, you can use the size attribute for our pre-defined font sizes. Or you can set a specific size by applying the font-size CSS property on the ion-icon component. It's recommended to use pixel sizes that are a multiple of 8 (8, 16, 32, 64, etc.)

How do I use Ionicons in HTML?

To embed an Ionicon in HTML all you have to do is copy the scripts from the installation section of the Ionicons and paste them in your HTML document. Afterward, select the Ionicon of your choice, copy the component code and paste it into your HTML document.

How do you change Ionicon title?

You may try disabling ion-icon popup using CSS event blocking and set "title" property on to a parent element. Or you can create Icon element using the below code as a workaround and set it on a button. Save this answer.


1 Answers

Similar to above, this is how I did it...

HTML:

<i class="ion-arrow-up-c rotate-90">

CSS:

.rotate-90 {
  display: inline-block; 
  transform: rotate(90deg);
}
like image 126
sam pierce Avatar answered Oct 20 '22 10:10

sam pierce