This is a discussion on "Trying to use CSS to style a form" within the Web Page Design section. This forum, and the thread "Trying to use CSS to style a form are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Trying to use CSS to style a form
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Hey everyone, having some problems here and i'm hoping you'll be able to help me out. I've been using CSS for a good while now in regards to layouts, but when it comes to forms i've always used tables. There was no reason really, i've just always done it that way. After doing my usual browsing of the forums I came across a post by ukgeoff saying that tables styling forms isn't really all that great so tonight I experimented using CSS to style them. I've had mostly success except for a few points.
What i've done is, i've floated labels to the left, and given them a set width (which is the size of the longest label, so they're all even). Alongside this, i've floated the text boxes to the left also so they all sit nicely together (and to be sure of this i've added a margin-right of ten pixels to the labels just for a nice little gap) That was all great and everything worked splendid, but whenever it comes to putting the form inside a div and centering it, i'm having major problems. I want everything inside my test div to be centred and it's just not happening. The more I play about the more I'm messing up my code so would you guys have a look at my code and see if a) It can be better put and b) figure out this div problem Oh and one other thing, To take a new line, what i've done is; The label floats to the left and also clears the left. The text box floats left. Whenever I add a new label, because it's set to clear the left, it takes a new line, but the text box screws up, it doesnt clear properly so I have to manually add a <br> break in, there must be a better way of doing this surely! You'll see what I mean if you take my code and take all the line breaks out. HTML
http://www.vrni.co.uk/form.htm Thanks in advance guys, Anthony |
|
|
|
|||
|
Re: Trying to use CSS to style a form
Cheers man, yeah I pondered using paragraph tags and breaks, and in the end I did end up using breaks but only because my floating failed. Surely there must be a way of doing it by floating right? Just for pure CSS perfection
|
|
||||
|
Re: Trying to use CSS to style a form
There is. But that isn't covered there.
__________________
I've got <style> and .class
|
|
||||
|
Re: Trying to use CSS to style a form
This works nicely
|
|
|||
|
Re: Trying to use CSS to style a form
Yeah that works great thanks a lot!
I've been analysing the code and I was wondering if you could answer a question for me. At the end of your code you use a paragraph and I don't understand why and how, I've read the css and I don't understand what it's doing. You make the paragraph's width 100% so it takes up the whole div, You give it a 12px margin top and bottom so that it is spaced out a bit, I'm not really sure what the 1px of padding is about, and I really don't know what overflow is about, i've seen the tag before but I don't know what it is and i've never had to use it! You float the button to the right but also make it a block element so should it not be on it's own line then? The label is also block so shouldn't it also have it's own line? I assume width:auto; just makes the size of the element match the length of it and nothing more? Sorry if this seems amateurish questions, Anthony |
|
||||
|
Re: Trying to use CSS to style a form
Quote:
Super simple clearing floats Quote:
Quote:
And keep asking questions. The only stupid questions are the ones that were never asked |
|
|||
|
Re: Trying to use CSS to style a form
Quote:
|
![]() |
| Tags |
| css, form, forms, layout, styling, styling forms |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Navigation with style | Frankiiei | Starting Out | 11 | Sep 27th, 2007 15:01 |
| style | MetallicWarfare | Starting Out | 12 | Aug 13th, 2007 09:00 |
| web style | littlebilly | Website Planning | 7 | Jul 22nd, 2007 14:58 |
| How to tell IE7 to use a pariticular style in a single style sheet | figo2476 | Web Page Design | 5 | May 25th, 2007 14:23 |
| Just for style? | timmytots | Web Page Design | 4 | Nov 17th, 2005 21:01 |