![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||||
| |||||
|
|
Hi, I have some simple HTML like this: |
|
div id="container" style="width:100%;" input type="text" > <input type="button" style="float:right;" value="Click here..." /div |
|
I want the button to remain the normal size and be right-aligned, and the edit box to automatically take up the remaining width of the container. |
|
I suspect I'm missing something obvious, |
|
but how can I do this with CSS? |
#3
| ||||||||||||
| ||||||||||||
|
|
Scripsit Mike Harrison: Hi, I have some simple HTML like this: Please post a URL, not a snippet of code. |
|
div id="container" style="width:100%;" input type="text" > <input type="button" style="float:right;" value="Click here..." /div "Click here..." is clueless. Just an example, maybe, but it's a _bad_ example, and people actually use such button texts, which are (literally) clueless, i.e. give no clue of the meaning and effect of the button. |
|
A text input field without a label is clueless, too. |
|
It is not obvious at all how the text field and the button relate to each other. If they do, why not use <fieldset> with a descriptive legend>? Then you have a _different_ styling problem, and perhaps one that is worth addressing. |
|
Besides, such a button is normally quite pointless, since <input type="button"> only works (if it works at all) via scripting, and there isn't any scripting in your snippet. |
|
So how about starting a from a good and real example, presented by providing the URL? |
|
I want the button to remain the normal size and be right-aligned, and the edit box to automatically take up the remaining width of the container. Really? Even if the canvas is ten meters wide? |
|
What happens when CSS is off? The width will be then set by browser defaults, which are rather small (typically, about 20 characters). So maybe you should first choose a suitable size="..." value; it's inconvenient guesswork, but it's better to make an intelligent guess that to let browsers default. |
|
I suspect I'm missing something obvious, We obviously miss the URL. but how can I do this with CSS? We miss the definition of what "this" consists of. |
|
To begin with, when the button element appears after the text input element, it will appear below it, though right-aligned. If you want them to appear on the same line visually, you need to put the button element before the text input element. You haven't actually made _any_ attempt to set the text input field width, in HTML or in CSS, in your snipped. The 100% width is set for the container element, for which it has no effect, since the default rendering is to make a <div> element as wide as possible. There does not seem to be any direct CSS way of achieving what you want (except using table-related properties that are not supported by IE), but it's trivial in HTML, with one simple piece of CSS: |
|
table width="100%" tr><td width="100%"><input type="text" style="width:100%"></td td><input type="button" value="Click here..."></td></tr /table |
|
However, what would be the point? If the field needs as much space as possible, why waste space by putting a button on its right? And why not make it a textarea if it may need a lot of space? |
#4
| |||
| |||
|
|
Scripsit Mike Harrison: [...] div id="container" style="width:100%;" input type="text" > <input type="button" style="float:right;" value="Click here..." /div "Click here..." is clueless. Just an example, maybe, but it's a _bad_ example, and people actually use such button texts, which are (literally) clueless, i.e. give no clue of the meaning and effect of the button. |
|
To begin with, when the button element appears after the text input element, it will appear below it, though right-aligned. If you want them to appear on the same line visually, you need to put the button element before the text input element. |
|
You haven't actually made _any_ attempt to set the text input field width, in HTML or in CSS, in your snipped. The 100% width is set for the container element, for which it has no effect, since the default rendering is to make a <div> element as wide as possible. There does not seem to be any direct CSS way of achieving what you want (except using table-related properties that are not supported by IE), but it's trivial in HTML, with one simple piece of CSS: |
#5
| |||
| |||
|
|
Final cluelessness/helpfulness (CH) quotient for the posting: 200%. |
#6
| |||
| |||
|
|
Scripsit Harlan Messinger: Final cluelessness/helpfulness (CH) quotient for the posting: 200%. No, your posting was completely unhelpful and stupid. You don't have anything useful to say, do you, but you apparently need to keep your fingers warm. How about using just Notepad for the exercise next time? |
#7
| |||
| |||
|
|
I read somewhere about a survey of which button/link texts people were most likely to click on. |
|
"Click here!" resulted in the most clicks because users have an attention span of four seconds, wish to remain clueless, and tend to just obey direct commands. |
|
.foo { display: block; overflow: hidden; /* to make it a BFC */ } input[type="text"] { width: 100%; } input[type="button"] { float: right; } ... input type="button" value="Click here" span class="foo" input type="text" /span |
#8
| |||
| |||
|
|
.foo { display: block; overflow: hidden; /* to make it a BFC */ } input[type="text"] { width: 100%; } input[type="button"] { float: right; } ... input type="button" value="Click here" span class="foo" input type="text" /span I'm not sure whether I'm convinced that this _should_ work, but |
|
a) it's more tricky than a simple table (with a simple CSS rule) b) on IE 7, it causes the right border of the input box hit the button; this looks odd and puzzling |
#9
| |||
| |||
|
|
Jukka K. Korpela wrote: Scripsit Mike Harrison: Hi, I have some simple HTML like this: Please post a URL, not a snippet of code. One doesn't need a URL of a fully formed page to ask how to do something. His illustrative snippet is short and clear. I'm awarding you one cluelessness point of your own. |
|
Final tally: 8 cluelessness points, 4 helpfulness points. Final cluelessness/helpfulness (CH) quotient for the posting: 200%. |
#10
| |||
| |||
|
|
In article <6cpte7F3g2eapU1 (AT) mid (DOT) individual.net>, Harlan Messinger <hmessinger.removethis (AT) comcast (DOT) net> wrote: Jukka K. Korpela wrote: Scripsit Mike Harrison: Hi, I have some simple HTML like this: Please post a URL, not a snippet of code. One doesn't need a URL of a fully formed page to ask how to do something. His illustrative snippet is short and clear. I'm awarding you one cluelessness point of your own. [...] Final tally: 8 cluelessness points, 4 helpfulness points. Final cluelessness/helpfulness (CH) quotient for the posting: 200%. I was slightly puzzled why you did not award a cluelessness point for the fault you theorised was due to attention deficit disorder. You are too soft hearted Harlan. <g Yes, sometimes pity gets the best of me. |
![]() |
| Thread Tools | |
| Display Modes | |
| |