• 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.

View More Info

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

CSS Animations via MooTools

JSON form builder

Using ASP.NET AJAX JSON Asynchronous Web Services

Growl for Windows and a Web Notification API

Learn AJAX from Scratch - Part II

Learn AJAX from Scratch - Part I


Our Partners

Ajax Projects

Web 2.0 Sites

Webloglines

Human Development Handbook

Software Development Company

Ajaxlines


Search


Topics

  • .Net (96)
  • Articles (76)
  • Bookmarking (35)
  • Calendar (18)
  • Chat (38)
  • ColdFusion (3)
  • CSS (31)
  • Email (23)
  • Flash (13)
  • Games (6)
  • Google (17)
  • Html (6)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (34)
  • Javascript (146)
  • JSON (17)
  • Perl (2)
  • PHP (82)
  • Presentation (19)
  • Python (3)
  • Resources (1)
  • RSS (1)
  • Ruby (7)
  • Storage (4)
  • Toolkits (87)
  • Tutorials (190)
  • UI (11)
  • Utilities (161)
  • Web2.0 (13)
  • XmlHttpRequest (18)
  • YUI (4)

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