)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to adjust the Height and Width of those stars in the rating control?

Platform: jQuery |
Control: ejRating |
Published Date: March 25, 2015 |
Last Revised Date: May 7, 2019
Tags: general

You can customize the size of rating control stars by using the custom CSS as the stars in the rating component are just sprite icons.

Customizing the size of the stars:

To increase the height and width of the stars, use smaller or larger sprite icons as per the requirement. By using the shapeHeight and shapewidth properties, you can increase the height of the wrapper of the element that holds the sprite image.

To include a sprite icon with the custom size (16x16) and to write the custom CSS to change other effects for this new sprite image use the following code:

HTML

<input id="mosRating1" type="text" class="rating" />

JavaScript

<script type="text/javascript">
        $(function () {
            $("#mosRating1").ejRating({
                value: 4,
                cssClass: "custom",
                shapeWidth:16,
                shapeHeight:16               
            });
        });
    </script> 

CSHTML

@Html.EJ().Rating("mosRating1").Value(3).CssClass("custom").Orientation(Orientation.Horizontal).Precision(Precision.Half).ShapeWidth(16).ShapeHeight(16)

ASPX

<ej:Rating CssClass="custom" ShapeWidth="16" ShapeHeight="16" runat="server"></ej:Rating>

CSS

.custom.e-rating.e-horizontal .e-shape-list,.custom.e-rating.e-vertical .e-shape-list,
.custom.e-rating.e-horizontal .e-shape,.custom.e-rating.e-vertical .e-shape,
.custom.e-rating.e-horizontal .e-ul,.custom.e-rating.e-vertical .e-ul,
.custom.e-rating.e-horizontal .e-reset,.custom.e-rating.e-vertical .e-reset {
    /*new 16x16 star sprite image*/
    background: url(images/rating.png) no-repeat;
    height: 16px;
    width: 16px;
}
/* Customization CSS for hover and active star */ 
.custom.e-rating .e-shape.inactive {
    background-position: 0 -205px;
}
.custom.e-rating .e-shape.active {
    background-position: 0 -82px;
}
.custom.e-rating .e-shape.selected {
    background-position: 0 -82px;
}
.custom.e-rating.e-horizontal .e-reset:hover,
.custom.e-rating.e-vertical .e-reset:hover {
    background-position: 0 -41px;
}
.custom.e-rating.e-horizontal .e-reset:hover,
.custom.e-rating.e-vertical .e-reset:hover {
    background-position: 0 -41px;
}
.custom.e-rating.e-horizontal .e-reset,
.custom.e-rating.e-vertical .e-reset {
    background-position: 0 0;
    margin-left: 2px;
}
.custom.e-rating.e-horizontal .e-shape-list,
.custom.e-rating.e-vertical .e-shape-list {
    background-position: 0 -205px;
    float: left;
}

The following screenshot is the output of the above code with the rating control star of 16x16 size.

                                                             Rating

                                                                    Rating control star with default size

                                                               Rating with default value

                                                                     Rating control star with 16X16 size

A sample with the rating image of 16 x 16 is available in the following location. In the same way, you can customize the size of the stars to various widths and heights. You can find the custom CSS and image on the content folder.

Sample location

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon