What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 17134 |  Welcome, Guest!   Register  Login
Home > Articles > CSS > How to use Transition,Text-Shadow and Border-Radius effect in CSS 3?

How to use Transition,Text-Shadow and Border-Radius effect in CSS 3?

2 vote(s)
Rating: 4.5 out of 5
Article posted by Sheonarayan on 3/27/2012 | Views: 5307 | Category: CSS | Level: Beginner | Points: 250 red flag


In this article we are going to learn, how to use transition, text-shadow and border-radius in CSS3.

Transition effects

Transitioning in CSS is changing the values of css property by interaction like hover, click focus etc.

In below code snippet, the background color and the font-size of the link change on mouse over. We can apply transition on width, opacity, position, font-size etc. In short you can say that you can apply transition to all the attributes of the element that can be specified in the numeric values.

Get HTML 5 and CSS 3 Online Training and 500+ ASP.NET web development Tips & Tricks here.

<style type="text/css">

/* width, opacity, position, font-size */

a.class1

{

padding: 5px 10px;

background-color: #9c3;

font-size: smaller;

width: 200px;

-webkit-transition: all 0.7s ease;

-moz-transition: all 0.7s ease;

-o-transition: all 0.7s ease;

transition: all 0.7s ease; /* transition: background 0.7s ease; */

}

a.class1:hover

{

background-color: #690;

font-size: larger;

width: 400px;

}

</style>

 

<a href="http://www.dotnetfunda.com" class="class1">DotNetFunda.com</a>

In case we want to transition only one property value, replace “all” with the property name like below. Here ease (the last parameter is the effect that should be considered while transition, currently this is not supported in most of the browsers).

In the above code snippet, you may notice that transition has been applied in four different lines of code with different prefix, these prefixes are browser specific prefixes.

  • -webkit- is for Google Chrome or the browser that supports -webkit- effects
  • -moz- is for Mozilla Firefox browser
  • -o- is for Opera browser
  • only transition is for other browser

transition: background 0.7s ease;

Output
 
 
On hover
 

 

Text-Shadow effects

Used to create a drop shadow beneath the selected text.

<style type="text/css">

a.class1

{

font-size: 50px;

text-shadow: 2px 3px 3px rgba(0, 0, 0, 0.5);

}

a.class1:hover

{

background-color: #690;

}

</style>

<a href="http://www.dotnetfunda.com" class="class1">DotNetFunda.com</a>

In the above code snippet, the DotNetFunda.com link comes with shadow.

a. The 1st argument of the text-shadow is horizontal offset
b. The 2nd argument of the text-shadow is vertical offset
c. The 3rd argument of the text-shadow is blur radius
d. The final argument is the color name

Output
 
 

Border-Radius effects

This property allows us to specify the border corner radius to make it rounded corer.

<style type="text/css">

a.class1

{

font-size: 50px;

text-shadow: 2px 3px 3px rgba(0, 0, 0, 0.5);

border-radius: 10px;

border: 1px solid #c0c0c0;

padding: 10px;

}

a.class1:hover

{

background-color: #690;

}

</style>

<a href="http://www.dotnetfunda.com" class="class1">DotNetFunda.com</a>

In the above code snippet, border-radius specifies the radius of the border corner.

Output
 
 

Hope this article was useful. Thanks for reading and hope that you liked it. 

Read my next article in this series How to use Opacity, Scale and box shadow and Zooming in CSS 3? here.

Keep an eye on forth coming articles on CSS 3. To read my series of articles, click here.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Sheo Narayan

Experience:8 year(s)
Home page:http://www.snarayan.com
Member since:Tuesday, July 08, 2008
Level:HonoraryPlatinum
Status: [Microsoft_MVP] [Administrator]
Biography:Microsoft MVP, Author, Writer, Mentor & architecting applications since year 2001.

Connect me on Facebook | Twitter | LinkedIn | Blog

 Responses
Posted by: Akiii | Posted on: 28 Mar 2012 12:24:14 AM | Points: 25

Good article Sir.
I have one question, does border radius is supported in IE 8 ?


Thanks and Regards
Akiii

>> Write Response - Respond to this post and get points
Related Posts

Here i am going to teach you a very nice and cool css effect. Creating circles with css. Is it that amazing. I have tested it in mozilla firefox and chrome browsers. and it works fine.

In this article we are going to learn, how to use Opacity, Scale and box shadow and Zooming effects in CSS 3.

This article describe how to write common css code to change the look and feel of html elements.

You must have came across some .css issues related with the browser behavior. Some of the styles that works in IE doesn't work in FireFox. In that situation you need to write conditional code for both browsers.

External style sheets have many powerful that make them ubiquitous in professional Web sites: It keeps your website design and content separate. It's much easier to reuse your CSS code if you have it in a separate file. Instead of typing the same CSS code on every web page you have, simply have many pages refer to a single CSS file with the "link" tag. You can make drastic changes to your web pages with just a few changes in a single CSS file. It allows a single style sheet to control the rendering of multiple documents. This results in a time-savings for the author, a savings of space for the web server, and less download time for the user. This method can be used in both HTML and XML.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 5:18:12 PM