Documente Academic
Documente Profesional
Documente Cultură
2007 telerik
CONTENTS:
Abstract
Step 1: Preparations
1.1. Choosing the Right Skin to Edit
1.2. Getting the Skin
1.3. Setting the Skin
Appendix:
5.1. Examples Server Tag
5.2. Examples HTML Output
5.3. r.a.d.tabstrip Classes Visually Explained
5.4. Useful r.a.d.tabstrip Resources
5.5. General CSS Knowledge
ABSTRACT
STEP 1: PREPARATIONS
Before we start, please, download the PhotoShop file we have used for the
example.
Select a skin from the existing ones that most resembles your design (for
convenience, we will call the target skin TelerikUniversity). Lets have a look at the
skins that we ship along with r.a.d.tabstrip and compare it with our design we
have rounded corners, relatively high tabs and the selected skin is a few pixels
higher than the other tabs, so in order to save time and effort, we should edit the
WebBlue skin:
TIP: You can create an .aspx page and paste the markup below. For detailed visual explanation of the
html structure, follow this link to the appendix of the tutorial.
TIP: To have e clear notion of the CSS classes and the HTML class they are applied to in r.a.d.tabstrip,
please take a look in the appendix section of this tutorial Tabstrip Classes Visually Explained.
And then reload the page. The new skin will look exactly the same as WebBlue
skin, but named TelerikUniversity:
Before we start, please take a look at the DOM-tree of r.a.d.tabstrip. For detailed
html structure, server declaration and css overview, please, follow this link to the
appendix of the tutorial.
To style the top (root) level tabs tabs of r.a.d.tabstrip, we need to edit three css
selectors, each one being a different part of the button:
Before editing the css we need to create the proper images, so open the .psd file
with PhotoShop, and using the rulers (Ctrl+R), outline the necessary elements for
the button the left, the middle and the right ones:
TIP: To avoid width issues later, make sure that the left and right images for the normal and selected
tabs have same widths. In the case of the TelerikUniversity it is 7 pixels.
TIP: An easy way to create the two images (TabLeft.gif and TabRight.gif) for the left and the right tab is
to cut the left image only, and then flip it horizontally (Image > Rotate Canvas > Flip Canvas Horizontal):
TabLeft.gif -
TabRight.gif -
- 7 x 33 pixels
- 7 x 33 pixels
Finally, lets create the middle image (TabMiddle.gif). Usually, in the css file, this
selectors background image is set to repeat-x, so in order to make things
lightweight, we cut only one pixel, which will repeat itself horizontally:
TabMiddle.gif -
- 1 x 33 pixels
2.2.1. LEFT
The padding-left and line-height properties represent the width and the height
of TabLeft.gif image, i.e. firstly we need to change them with the proper values in
order to set the correct width and height of the new image, i.e. padding-left: 7px;
line-height: 33px;. Then we set the proper color of the link color: white; or
color: #fff or color: #ffffff;
6
.RadTabStrip_TelerikUniversity li a
{
padding-left: 7px;
line-height: 33px;
color: white; /* or #fff, #ffffff */
background: transparent url('img/TabLeft.gif') 0px 0px no-repeat;
text-decoration: none;
}
TIP: The other two properties background and text-decoration are usually constant and are not changed
during the process of creating a skin.
TIP: This selector is also the place where we could specify properties for the onmoouseover of the
tabstrip, for example:
.RadTabStrip_TelerikUniversity li a:hover
{
color: orange;
}
2.2.2. RIGHT
Exactly the same is the situation with the right part of the tab button, with the only
difference that here we set padding-right instead of padding-left:
.RadTabStrip_TelerikUniversity li a .wrap
{
padding-right: 7px;
line-height: 33px;
background: transparent url('img/tabRight.gif') right 0px norepeat;
}
2.2.3. MIDDLE
.RadTabStrip_TelerikUniversity li a .innerWrap
{
line-height: 33px;
background: transparent url('img/tabMiddle.gif') 0px 0px repeatx;
text-align: center;
}
and then reload the page. Having skinned the normal state of the tabs, you will
have the following result:
TIP: For detailed instructions, please, have a look at STEP 2: CREATING THE NORMAL STATE
OF THE TABS
The situation with the selected state of the tab is similar to the normal tab button.
Again we have three classes to which we have to set proper values and images:
TabLeftSelected.gif -
- 7 x 33 pixels;
TabRightSelected.gif -
- 7 x 33 pixels;
TabMiddleSelected.gif -
- 1 x 33 pixels;
Edit the classes in the same way as we did with the Left classes:
.RadTabStrip_TelerikUniversity li a.selected
{
padding-left: 7px;
8
line-height: 33px;
background: transparent url('img/TabLeftSelected.gif') 0px 0px
no-repeat;
}
By design, the text of the tabstrip buttons is in uppercase. Obviously, this could be
easily achieved simply by typing the text with Caps Lock button pressed, but this
could also be done with css, by using the text-transform property, applied to the
outermost element of r.a.d.tabstrip:
.RadTabStrip_TelerikUniversity
{
font: 11px Arial, Verdana, Sans-serif;
9
text-transform: uppercase;
}
To bold any text within r.a.d.tabstrip, we simply add the bold property to the
.RadTabstrip_TelerikUniversity class:
.RadTabStrip_TelerikUniversity
{
font: bold 11px Arial, Verdana, Sans-serif;
text-transform: uppercase;
}
and we get:
TIP: Adding properties to the wrapping element, i.e. .RadTabstrip_TelerikUniversity will cause any
child element to cascadingly inherit these, so if we need other settings for the child classes, we have to
specify them separately in the relevant classes.
10
By design, we have 30 pixels left and right padding of the tab text. 7 pixels are
already compensated with the left and right padding we have added to the
.RadTabStrip_TelerikUniversity li a and .RadTabStrip_TelerikUniversity
li a .wrap selectors. For the remaining 23 pixels, we add padding to the
.RadTabStrip_TelerikUniversity li a .innerWrap selector:
.RadTabStrip_TelerikUniversity li a .innerWrap
{
line-height: 33px;
background: transparent url('img/tabMiddle.gif') 0px 0px repeatx;
text-align: center;
padding-left: 23px;
padding-right: 23px;
}
TIP: In the cases where we have several paddings (top, right, bottom, left) used, we may use the
shorthand property, instead of adding all four properties:
.RadTabStrip_TelerikUniversity li a .innerWrap
{
line-height: 33px;
background: transparent url('img/tabMiddle.gif') 0px 0px repeat-x;
text-align: center;
padding-left: 23px;
padding-right: 23px;
padding: 4px 23px 0 23px; /* top, right, bottom, left */
}
It is important to have in mind the order of the values in these cases it is clockwise, i.e. top, right,
bottom, left.
11
As you can see, our design requires tab buttons to be 1 pixel offset from each other.
To achieve this, we have to set proper margin to two selectors:
.RadTabStrip_TelerikUniversity li a
{
margin-right: 1px;
padding-left: 7px;
background: transparent url('img/TabLeft.gif') 0px 0px no-repeat;
line-height: 33px;
color: white;
text-decoration: none;
}
.RadTabStrip_TelerikUniversity li a.selected
{
margin-right: 1px;
padding-left: 7px;
12
Usually, the line-height property centers the tab text vertically. In fact, in our case
it is also centered, but as visually the normal tabs are smaller than the selected
ones, we have to add some padding (in our case it is 4px) to the innermost tab
elements of the relevant selectors:
.RadTabStrip_TelerikUniversity li a .innerWrap
{
line-height: 33px;
background: transparent url('img/tabMiddle.gif') 0px 0px repeatx;
text-align: center;
padding-left: 23px;
padding-right: 23px;
padding-top: 4px;
}
and here goes the final version of the new TelerikUniversity skin for
r.a.d.tabstrip:
Making r.a.d.tabstrip tabs overlapping is also done with css by applying negative
margin to the proper selectors. Although the design of TelerikUniversity skin does
not require it, we may test this important feature.
.RadTabStrip_TelerikUniversity li a
{
padding-left: 7px;
background: transparent url('img/TabLeft.gif') 0px 0px no-repeat;
line-height: 33px;
color: white;
text-decoration: none;
margin-right: -7px;
14
.RadTabStrip_TelerikUniversity li a.selected
{
padding-left: 7px;
background: transparent url('img/TabLeftSelected.gif') 0px 0px
no-repeat;
line-height: 33px;
margin-right: -7px;
}
15
To enhance visually the appearance of disabled tabs for Mozilla and Opera, we
specify cursor and text-decoration:
.RadTabStrip_TelerikUniversity li a.disabled,
.RadTabStrip_TelerikUniversity li a.disabled .wrap,
.RadTabStrip_TelerikUniversity li a.disabled .innerWrap
{
cursor: no-drop; /* IE, Mozilla, Opera */
text-decoration: line-through; /* IE, Mozilla, Opera */
}
APPENDIX:
17
r.a.d.tabstrip overview
18