Click here to Skip to main content
Click here to Skip to main content

HTML5/CSS3 graphic enhancement: buttons, inputs

By , 9 Oct 2012
 

Introduction

Suggested technique does not require any graphic files like .jpg or .png, etc. All aesthetic enhancements, like: rounded corners, color gradients, borders and shadows are achieved exclusively via CSS3 styling, thus resulting in very small digital footprint and fast web page load. Following code snippet demonstrates novel styling technique using HTML5/CSS3 advanced features: rounded corners, gradients (in particular, color-stop property), shadows applicable to HTML5 elements, in particular, input, button and div elements.

Demo

Working demo of HTML5/CSS3 enhanced web application is available at:

Engineering Calculator VOLTA-2011[^].

Sample screenshot of online Engineering Calculator VOLTA-2011 utilizing the discussed HTML 5 graphic features follows:

Engineering Calculator VOLTA-2011

 

Aesthetic HTML5 Button elements 

All aesthetic enhancements are achieved via CSS3 styling; project does not use any graphic.

Listing 1
<!DOCTYPE HTML>
<html>
 <head>
    <title>AESTHETIC BUTTONS | HTML5, CSS3</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <meta http-equiv="Author" content="Alexander Bell" />
    <meta http-equiv="Copyright" content="2011 Alexander Bell" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache-control" content="no-cache">
    <meta name="Robots" content="all" />
    <meta name="Distribution" content="global" />
    <meta name="Keywords" content="HTML5, CSS3, Buttons, CalculatorS " />
    <meta name="Description" content ="Aesthetic buttons with Gradient and Rounded Corners, HTML5, CSS3" />
   <!--CSS-->
   <style type="text/css">
    input
    {
        width:80px;
        height: 60px;
        line-height:60px;
        vertical-align:middle;
        margin: 0px;
        padding: 0px;
        cursor: pointer;
        cursor: hand;
        font-family: Arial, Tahoma, Verdana, Calibri;
        font-size: 28pt;
        text-align: center;
        background:#404040;
        border: 2px solid #ababab;
        color: #dadada;
        -moz-border-radius: 10px;
        -webkit-border-radius: 10px;
        border-radius: 10px;
    }
    input:hover  { font-weight:bold;}
    input:active { border: 2px; }
 
    .btnType1{
        background: -moz-linear-gradient(top, #707070, #505050 48%, #bababa 50%, #303030 52%, #101010);
        background: -webkit-gradient(linear, center top, center bottom, from(#707070), color-stop(0.48, #505050), color-stop(0.5, #bababa ), color-stop(0.52, #303030), to(#101010));
    }
    .btnType2{
        background: -moz-linear-gradient(top, #dadada, #505050 5%, #bababa 50%, #bababa 50%, #303030 52%, #101010);
        background: -webkit-gradient(linear, center top, center bottom, from(#707070), color-stop(0.48, #505050), color-stop(0.5, #bababa ), color-stop(0.52, #303030), to(#101010));
    }
    .btnType3{
        background: -moz-linear-gradient(top, #dadada, #707070 5%, #515151 50%, #bababa 50%, #303030 52%, #101010);
        background: -webkit-gradient(linear, center top, center bottom, from(#707070), color-stop(0.48, #505050), color-stop(0.5, #bababa ), color-stop(0.52, #303030), to(#101010));
    }
    .btnType4{
       color:#505050;
       background: -moz-linear-gradient(top, #f0f0f0, #bababa 10%, #cacaca 46%, #909090 48%, #dadada 52%, #cacaca 54%, #cacaca 90%, #ababab);
       background: -webkit-gradient(linear, center top, center bottom, from(#f0f0f0), color-stop(0.1, #bababa ), color-stop(0.46, #cacaca), color-stop(0.48, #909090), color-stop(0.52, #dadada ), color-stop(0.54, #cacaca), color-stop(0.90, #cacaca), to(#ababab));
    }
    .btnType5{
        color:#505050;
        background: -moz-linear-gradient(top, #f0f0f0, #cacaca 48%, #707070 50%, #cacaca 52%, #fafafa);
        background: -webkit-gradient(linear, center top, center bottom, from(#f0f0f0), color-stop(0.48, #cacaca), color-stop(0.5, #707070 ), color-stop(0.52, #cacaca), to(#fafafa));
    }
    .divClear { clear:both;}
   </style>
  </head>
  <body>
    <input type ="button" button value="A" class="btnType1" />
    <input type ="button" button value="L" class="btnType1" />
    <input type ="button" button value="E" class="btnType1" />
    <input type ="button" button value="X" class="btnType1" />
    <input type ="button" button value="A" class="btnType1" />
    <input type ="button" button value="N" class="btnType1" />
    <input type ="button" button value="D" class="btnType1" />
    <input type ="button" button value="E" class="btnType1" />
    <input type ="button" button value="R" class="btnType1" />
    <div class="divClear"></div>
    <input type ="button" button value="B" class="btnType2" />
    <input type ="button" button value="E" class="btnType2" />
    <input type ="button" button value="L" class="btnType3" />
    <input type ="button" button value="L" class="btnType3" />
    <input type ="button" button value="2" class="btnType4" />
    <input type ="button" button value="0" class="btnType4" />
    <input type ="button" button value="1" class="btnType5" />
    <input type ="button" button value="1" class="btnType5" />
 </body>
</html> 
Design Notes

The shadow effect could be implemented by the following CSS code block:

Listing 2
/* add shadows */
-moz-box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
-webkit-box-shadow: 5px 5px 10px rgba(0,0,0,0.3);
box-shadow: 5px 5px 10px rgba(0,0,0,0.3);

Adding Tooltips. Further enhancement could be achieved by adding the context-sensitive help (a.k.a. Tooltips) to the buttons by using HTML elements "abbr" or "acronym". In this case no any Javascript is needed; the pop-up text will correspond to the title attribute of the abbr tag. Listing 3 demonstrates the sample implementation of this feature, pertinent to the Calculator Volta 2011

Listing 3
<nav>
    <menu id="menu1" class="oscMenu">
    <li>
        <abbr title="Return to the front page"><a href="http://www.webinfocentral.com/math/Calculators.aspx">HOME</a></abbr>
    </li>
    <li id="active">
        <abbr title="Read Instruction online"><a href="http://exm.nr/ExmVolt" target="_blank">INSTRUCTION</a></abbr>
    </li>
    <li>
 
        <abbr title="Read online Documentation"><a href="http://exm.nr/VoltDN" target="_blank">DOC</a></abbr>
    </li>
    </menu>
</nav>

Points of Interest

Browser compatibility

Major Web Browsers support new HTML 5/CSS3 features, though recently released Internet Explorer 9.0 (IE9) has limited capability of rendering color gradients and some other CSS attributes (see the following feature matrix):

  • Rounded corners (works in FF/Chrome/Safari/IE9)
  • Box shadows (works in FF/Chrome/Safari/IE9)
  • Color gradients (works in FF/Chrome/Safari)
  • Text shadows (works in FF/Chrome/Safari)
  • Text rotation (works in FF/Chrome/Safari) 
Calculator VOLTA-2011 tested on new Apple iPad

Read the entire article on Examiner: New iPad 3 is here: quick notes from Apple store on Fifth (Mar 17, 2012)

More reading on this topic is available online at [1...3].

Announcement

Updated version of Engineering Calculator VOLTA-2012 is currently under development. See the project submission to "Ultrabooks" contest.

References

  1. Online Engineering Calculator Volta-2011, User Manual[^]
  2. Online Engineering Calculator Volta-2011, Design Notes[^]
  3. Scientific Calculator ZENO-5000, Code Project[^]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

DrABELL
Chief Technology Officer Infosoft Int'l
United States United States
Member
Dr. A. Bell has 20+ years of SW/EE experience, published 200+ tech articles and authored 37 inventions; Win/Web veteran, currently focused on: HTML5, CSS3, Javascript, jQuery, SQL, Windows 8, .NET, C#, WPF, Ultrabooks, Mobile. Developed popular Silverlight Media Player, 3 Fractions Calculator and best YouTube API for ASP.NET (#1 Goog). Sample pubs/projects:
  1. HTML5 Best Practices: Table formatting via CSS3
  2. Personal computer 2012
  3. New iPad: notes from NY Apple store
  4. YouTube and Facebook popularity metrics
  5. Edumatter M12: School Math Calculators and Equation Solvers
  6. How to select web browser and check its capabilities
  7. SQL generates large data sequence
  8. Aggregate Product function extends SQL
  9. Top-50 Digital Cameras
  10. Evolution of digital cameras
  11. WebTV Project: Embedded YouTube Player

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5membersravani.v5 Oct '12 - 0:04 
GeneralRe: My vote of 5memberDrABELL5 Oct '12 - 2:16 
GeneralReason for my vote of 5 nice articlemembernikhi _singh13 Feb '12 - 18:09 
GeneralRe: Many thanks for your note/vote!memberDrABELL13 Feb '12 - 18:39 
GeneralReason for my vote of 5 coolmemberJucer10 Feb '12 - 15:19 
GeneralRe: Reason for my vote of 5coolmemberDrABELL4 Oct '12 - 13:11 
Thanks!
GeneralReason for my vote of 5 so easy, so simple and cleanmemberitaitai1 Nov '11 - 22:25 
GeneralRe: Many thanks!memberDrABELL2 Nov '11 - 4:38 
GeneralImpressive design :)memberkiran dangar30 Sep '11 - 3:06 
GeneralRe: Thanks!memberDrABELL30 Sep '11 - 15:53 
GeneralReason for my vote of 5 Very nice!memberSpliffa27 Sep '11 - 4:44 
GeneralRe: Thank you!memberDrABELL27 Sep '11 - 5:20 
GeneralReason for my vote of 1 to goodmemberbhupatpatel17 Sep '11 - 8:30 
GeneralRe: Frankly speaking, it's a bit confusing: why did you rate my ... [modified]memberDrABELL17 Sep '11 - 9:49 
GeneralReason for my vote of 5 Nice graphics.memberjknickel13 Sep '11 - 20:51 
GeneralRe: Many Thanks!memberDrABELL14 Sep '11 - 1:28 
GeneralReason for my vote of 5 very helpfulmemberitaitai13 Sep '11 - 19:34 
GeneralRe: Thank you!memberDrABELL14 Sep '11 - 1:27 
GeneralSorry. Clicked the wrong place, in error. Still. A great p...memberSteve Stark12 Sep '11 - 15:48 
GeneralRe: Thanks! :)memberDrABELL13 Sep '11 - 2:15 
GeneralReason for my vote of 5 Nice looking calculator, thanks for ...memberBrianBissell6 Sep '11 - 5:31 
GeneralRe: You are very welcome, Brian! Regards - ABmemberDrABELL6 Sep '11 - 7:08 
GeneralReason for my vote of 5 Amazing, very-very good article DrAB...memberKurniawan Prasetyo5 Sep '11 - 21:32 
GeneralRe: Many Thanks!memberDrABELL6 Sep '11 - 0:57 
GeneralSorry, it took me a while to find the comment link. Anyway, ...membersobiyang5 Sep '11 - 17:14 
GeneralRe: You are welcome! My best - ABmemberDrABELL5 Sep '11 - 17:50 
GeneralReason for my vote of 5 Nice!subeditorWalt Fair, Jr.31 Aug '11 - 8:29 
GeneralRe: Thanks!memberDrABELL31 Aug '11 - 16:14 
GeneralReason for my vote of 5 THANK'Smemberashishkumar00827 Jun '11 - 17:38 
GeneralRe: You are very welcome! Likewise, thanks for visiting and voti...memberDrABELL28 Jun '11 - 3:02 
GeneralReason for my vote of 5 NICE...memberashishkumar00825 Jun '11 - 11:08 
GeneralRe: Thanks, Ashish!memberDrABELL25 Jun '11 - 12:36 
Generalgreat. nice head on to html 5.memberAmitMangal4 May '11 - 0:50 
GeneralThanks a lot, Deeksha! Kind regards, ABmemberDrABELL30 Apr '11 - 3:35 
Generalnice my5.memberMonjurul Habib29 Apr '11 - 20:28 
GeneralRe: Many Thanks!memberDrABELL30 Apr '11 - 3:24 
GeneralOutstanding yet simple. Cool woork.memberezekjh27 Apr '11 - 10:39 
GeneralRe: Many thanks, folks! Best regards, AlexmemberDrABELL27 Apr '11 - 15:16 
GeneralGreat job..memberShahriar Iqbal Chowdhury27 Apr '11 - 10:03 
GeneralRe: Thanks!memberDrABELL27 Apr '11 - 10:15 
GeneralReal nice work! Ultimate man!memberGPUToaster21 Mar '11 - 19:53 
GeneralRe: Thanks!memberDrABELL22 Mar '11 - 2:22 
GeneralReason for my vote of 5 nice onememberPranay Rana25 Feb '11 - 2:58 
GeneralRe: Many thanks, Pranay!memberDrABELL25 Feb '11 - 3:44 
GeneralReason for my vote of 5 nice :)memberBryian Tan24 Feb '11 - 5:15 
GeneralRe: Thanks, Bryian! :)memberDrABELL24 Feb '11 - 5:36 
GeneralReason for my vote of 5 Wonderful!!!membermaq_rohit24 Feb '11 - 1:30 
GeneralRe: Thanks! :)memberDrABELL24 Feb '11 - 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 9 Oct 2012
Article Copyright 2011 by DrABELL
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid