Designing of Beautiful Contact Form

by admin
Posted January 15th, 2010 at 9:56 am

I hope that this will be an interesting tutorial for you. I want to demonstrate that how I style my form input fields that is cross browser compatible all with just CSS. This is totally a new layout.

All of us creates forms on websites, it may be a blog, e-commerce or even a personal site. The way I did it in the past was declared a background image on the input element which I soon found will not work correctly. Instead I needed to put the background image on a hook like a paragraph tag and absolutely position the input element within the background image thus allowing full control of the position of the text input. Lets checkout first that what we will achieve.

I took the liberty of commenting anything that is not immediately clear in the CSS.

Now let’s take a look at the code.

HTML

<form id="nice-form" method="post"> <fieldset>
<legend>Nice Contact Form</legend>
<label for="name">Name:</label>
<input name="name" type="text" /><label for="email">Email:</label>
<input name="email" type="email" /><label for="message">Message:</label>
<textarea cols="40" rows="10" name="message"></textarea>
</fieldset>
<input name="submit" type="submit" value="Submit" /> </form>

CSS

html, body {
margin:0;
padding:0;
}
#wrapper {
margin:0 auto;
width:960px;
}
fieldset {
border:none;
}
legend {
font-size:30px;
color:#BD2B7B;
font-family:Georgia, "Times New Roman", Times, serif;
}
#nice-form {
float:right;
margin:20px auto;
width:470px;
}
#nice-form label {
text-indent:-9999px; /*  Move the text off the screen while still keeping accessibility */
display:inline-block;
}
#nice-form p.name {
background:url(../images/nameinput.png) no-repeat scroll top left;
width:446px;
height:62px;
position:relative; /* To allow child containers to be positioned absolutely */
clear:both;
display:block;
}
#nice-form p.name input {
position:absolute; /* To position this container absolutely inside of #nice-form p.name parent container */
top:10px;
left:130px;
border:none; /* By default, the input field will show a border/box, this sets it to not display anything */
font-size:30px;
width:300px; /* This keeps the text within the background image so the text will not type outside of that area */
background:none; /* This sets the background color to none so you will not see a default white */
font-family:Georgia, "Times New Roman", Times, serif;
color:#999;
display:block;
}
#nice-form p.email {
background:url(../images/emailinput.png) no-repeat scroll top left;
width:446px;
height:62px;
position:relative;
clear:both;
display:block;
}
#nice-form p.email input {
position:absolute; /* To position this container absolutely inside of #nice-form p.name parent container */
top:10px;
left:130px;
border:none; /* By default, the input field will show a border/box, this sets it to not display anything */
font-size:30px;
width:300px; /* This keeps the text within the background image so the text will not type outside of that area */
background:none; /* This sets the background color to none so you will not see a default white */
font-family:Georgia, "Times New Roman", Times, serif;
color:#999;
display:block;
}
#nice-form p.textarea {
background:url(../images/textinput.png) no-repeat scroll top left;
width:446px;
height:302px;
position:relative;
}
#nice-form p.textarea textarea {
position:absolute; /* To position this container absolutely inside of #nice-form p.name parent container */
top:20px;
left:140px;
border:none; /* By default, the input field will show a border/box, this sets it to not display anything */
font-size:20px;
width:290px; /* This keeps the text within the background image so the text will not type outside of that area */
background:none; /* This sets the background color to none so you will not see a default white */
font-family:Georgia, "Times New Roman", Times, serif;
color:#999;
overflow:auto; /* This ensures that there should be any text overflow, it would automatically determine to use vertical and horizontal scrollbars */
display:block;
}
#nice-form .button {
background:url(../images/button.png) no-repeat top left;
width:121px;
height:57px;
text-indent:-9999px;  /*  Move the text off the screen while still keeping accessibility */
border:none; /* This sets the background color to none so you will not see a default white */
cursor:pointer; /*Since we are using a background image, this will set the mouse cursor to change when hovering over so you know it is a clickable button */
overflow:hidden; /* hides any graphic/image element if it overflows */
display:block;
line-height:0; /* this is really a hack for IE6 and IE7 because text-indent will not work here unless the line-height is set to zero */
}

This technique has been tested on IE6,IE7,IE8,FF (latest), Opera (latest), Safari (latest), and Chrome (latest).

Although I know this wasn’t a step by step tutorial but I figure the comments on the stylesheet should explain most of whats going on. But if for some reason you think this does not suffice, please let me know and I will write this out in a tutorial step by step style. Enjoy and have fun!

  • Stumbleupon
  • Delicious
  • Google Buzz

Popularity: 100% [?]

http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/digg_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/reddit_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/dzone_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/delicious_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/blinklist_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/blogmarks_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/furl_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/technorati_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/myspace_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/facebook_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/sphinn_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/mixx_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/twitter_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/jamespot_48.png http://www.tutorialspalace.com/wp-content/plugins/sociofluid/images/meneame_48.png

Random Posts



-->
3 ResponsesLeave a comment
  • Tutorial Lounge
    January 16, 2010 at 6:44 am

    really helping development training for contact form.

  • Design Agency Northampton
    February 20, 2010 at 9:43 am

    Very helpful thanks, but would be useful to have a demo, or have I just missed it?

Add a commentGet a Gravatar

* Name

* Email Address

Website Address

You can usethese tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Sponsors
Advertise with us!
Around The Site
Free Subscription

Enter your email address:

 
Design Resources
Friends Links
Galleries
Categories
Tags
Archives
Community News
  • Text written by WaterMarch 10, 2010

    It is very nice technique to make water drops so that you may apply Layer Styles to any text or object to give water look. It seems that name has been written by real water. Hope you will like this.

  • Desktop Wallpaper: 80+ Most Breathtaking Places on EarthMarch 10, 2010

    There are many sources of inspiration that designers look to when trying to get their creative juices flowing. I think there is none better than the breathtaking landscapes that nature has to offer. In this post you will see some of the most beautiful p…

  • 70 Exceptional Creative Typography Desktop WallpapersMarch 9, 2010

    We always present quality stuff for you respected visitors and readers, today we have some modern and latest typography wallpapers, we simply presenting beautiful and inspiring to look at I think, typography art to desktop wallpapers seams to be quite c…

  • 50 Hot New Tutorials (Part1)March 9, 2010

    Tutorials can often be your greatest source of inspiration when trying to design that project you have been putting off. In this post, I have rounded up a collection of very useful tutorials from around the web from the month of February. You’ll find …

  • See Through Glass Tutorial – Glass TransparencyMarch 9, 2010

    In this Tutorial I’m going to show scene behind a Glass. I mean suppose you have a Glass picture and you want to place it on another picture but also wanted to see the scene through the Glass. I got this tutorial after working hard, because it is very…

  • How to Create a Fancy Image Gallery with CSS3March 9, 2010

    Today, I have prepared a tutorial about how to use CSS3 to make an image gallery with animation. I recommend to use one of these browsers to see the animations; however, the gallery is going to be usable in browsers without support of the animation.

  • How to create a web hosting layoutMarch 8, 2010

    Learn how to create a nice looking web hosting layout with this easy to follow tutorial.

  • 30 Stunning Graphical Vector Tutorials for Improve your Graphics SkillsMarch 8, 2010

    Vector graphics is playing major role in designing world, specially in Print Media where we can draw characters, shapes and other creative illustrations. Vector applications such as Adobe Illustrator that are used to create scalable graphics are ideal f…

  • 30 Latest High-Quality Free (X)HTML/CSS Templates Must See NowMarch 7, 2010

    Thanks to all designers and developers from all over the world who freely distributed their high-quality templates for everyone on web. In this showcase below, you’ll find a 30 Latest High-Quality Free (X)HTML/CSS Templates Must See Now because We all…

  • Create a clean and light business layoutMarch 6, 2010

    Learn how to create an awesome clean business layout with this step by step tutorial.

Read More News
Add News




Captcha
To prevent spam, please type the text (all uppercase) from this image in the textbox below.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes