• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

Creating Resizeable Buttons in CSS ...

Have you ever designed a page for a web application and wanted to make a nice button for the application? You probably opened your photo editor and started working on the button. But, what if your design resizes itself based on the users browser size? You will probably want the button to resize as well. Well, over at CSS Globe they have written a script to do just that using CSS.

Below is an excerpt from the article explaining the concept.

    Concept

    This concept is probably familiar to you from various navigation tab styling techniques. We have one long background image:





This one is 550px wide. I believe that is more than sufficient for buttons

So, we apply this image as a background image of a top element (in this case SPAN), place it to top left and add some left padding. Nested element (in this case EM) have the same background image but placed to top right and with right padding. As the content text grows so will the button.


Height of the button is fixed in my example but you can use similar technique and some more markup and place the same background image to all 4 corners.

    To make sure that the text is vertically centered I use line-height property.

The HTML that is required for applying the CSS to would be the below.

    <button><span><em>Button text</em></span></button>

The below is the CSS that is used.

    button{
        border:none;
        background:none;
        padding:0;
        margin:0;
        width:auto;
        overflow:visible;                   
        text-align:center;   
        white-space:nowrap;   
        height:40px;
        line-height:38px;           
        }
    button span, button em{
        display:block;
        height:40px;
        line-height:38px;           
        margin:0;
        color:#954b05;
        }
    button span{
        padding-left:20px;
        background:url(bg_button.gif) no-repeat 0 0;
        }   
    button em{
        font-style:normal;
        padding-right:20px;
        background:url(bg_button.gif) no-repeat 100% 0;
        }

source: ajaxonomy

 View Full Story.
Posted at 01:58:50 pm | Permalink | Posted in CSS  Tutorials  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

Be the first ... |Add your comment.

Your Comment ...

  Name (required)

  Email (required, hidden)

  Website


About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Recent Stuff

Making AJAX Ro(a)R

Ruby on Rails Applications Development with Ajax

Facebook Drops Another Hurdle

FBJS and Ajax to acheive Facebook profile link tracking

Getting a JavaScript stracktrace in any browser

Ajax data picker Javascript


Our Partners

Facebook Applications

Ajax Projects

Web 2.0 Sites

Webloglines

Human Development Handbook

Software Development Company

Ajaxlines

Stock Exchange Chat


Search


Topics

  • .Net (109)
  • Articles (82)
  • Bookmarking (35)
  • Calendar (19)
  • Chat (39)
  • ColdFusion (3)
  • CSS (37)
  • Email (23)
  • Facebook (19)
  • Flash (15)
  • Games (6)
  • Google (26)
  • Html (13)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (36)
  • Javascript (169)
  • JSON (21)
  • Perl (2)
  • PHP (87)
  • Presentation (19)
  • Python (3)
  • Resources (2)
  • RSS (1)
  • Ruby (9)
  • Storage (4)
  • Toolkits (90)
  • Tutorials (196)
  • UI (11)
  • Utilities (166)
  • Web2.0 (13)
  • XmlHttpRequest (20)
  • YUI (4)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange