it will end up making the input field longer than the <div> block. Why? Where does this extra padding come into play? I’ve set the padding on the input field to 0 and it still goes beyond. Can anyone explain what’s going on with that? Thanks.
it will end up making the input field longer than the <div> block. Why? Where does this extra padding come into play? I’ve set the padding on the input field to 0 and it still goes beyond. Can anyone explain what’s going on with that? Thanks.
I would guess that the borders on the input are playing a role in this. I’m not a form expert by no means, still learning myself. I can get what you are after by setting the 200px width on the input and giving it an inline-block display;
Then remove the width from the parent div and let it shrink wrap with inline-block also. Tested in FF3, Opera & Safari.
The example works by adding padding to the parent equal to the border width (and any extra padding you want on the input) and then setting the input to 100% wide. This makes it too big but then its dragged back into the padding of the parent using negative margins and then fits exactly.
Hi Paul
Yes I had seen that method you used for textareas. It looks like it’s just a basic neg-margin drag into parent padding with more favor to the left margin.
I expected that it all should have been wrapped in a form element too, just now cutting my teeth with forms. I avoided them for a long time but now I am regretting that since I have some coming up on a project.
I just ran into an issue with IE6/7 and a floated form, I will post a thread and see what your thoughts are on that.
Agreed. Forms are such a pain. I’m working on a Wufoo type project where developers can create the form visually and then have it write all the code complete with css theme for the CodeIgniter framework. It’s nice because you can tell it to save to a database, pull the record from a database to prepopulate the form and/or email the form.
It just take so long to put those pieces together and have it be consistant without errors throughout your application/site.
I thought it’d be nice to only have to change the main div wrapper’s width for the form so that the form fields can stretch to the end of the div wrapper or be half it’s size, etc. I’m thinking this isn’t the best way. I guess pixels it is.
I thought it’d be nice to only have to change the main div wrapper’s width for the form so that the form fields can stretch to the end of the div wrapper or be half it’s size, etc.
As Paul said, as long as you don’t change the input at all then Pauls way will work. He does 100%width/border and then drags it over witrh a negative margin equating the total borders (and padding if he set, I forget).