473,465 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

background color of a textbox

Hello,

I was wondering if there is any cross-browser CSS way to specify that I
want the background color of a readonly input text field to be the same
as its parent row. Right now, I have

<tr class="myRowClass">
<td align="right">Account Username</td>
<td align="left">
<div id="loginMsg" name="loginMsg"><input
style="color:red; font-size:90%" type="text" readonly id="msg"
name="msg" value="" size="120"></div>

For the input with id "msg", currently on Firefox and IE the background
is white, even though the row background is blue.

Thanks for any advice, - Dave

Jan 19 '06 #1
1 11455
la***********@zipmail.com wrote:
I was wondering if there is any cross-browser CSS way to specify that I
want the background color of a readonly input text field to be the same
as its parent row.
An input field cannot have a (table) row as its parent, only as a more
remote ancestor.

The most useful piece of advice here is probably this: don't mess around
with styling forms, and in particular don't use any fancy background,
and especially if you use readonly fields (you normally shouldn't),
don't prevent browsers from rendering them as readonly to the extent
they can.

Since people so seldom wish to make use of the best advice, here's the
less relevant tech stuff:
<div id="loginMsg" name="loginMsg"><input
style="color:red; font-size:90%" type="text" readonly id="msg"
name="msg" value="" size="120"></div>
Setting the size to 120 is wrong. There's no sense in making the visible
width of a field 120 characters. If you expect such an amount of data,
use textarea.
For the input with id "msg", currently on Firefox and IE the background
is white, even though the row background is blue.


No, the background of the input element is what other style sheets say,
since your style sheet does not say anything about it. For all that you
can know, it could be red.

You could use background: transparent for the <input> element. In
principle, you should use the same for the <div> element enclosing it
(why do you have that markup?) and for the enclosing <td>, but in
practice their backgrounds most probably default to transparent.

In theory, you could also use background: inherit, which is what you are
asking for. But it's poorly supported: no support on IE.

On the other hand, by setting the background, you make it more difficult
to users to recognize that the input field is disabled.

I wonder what might be a justifiable reason to make a field for login
meesage readonly. After all, the only way to change the readonly status
is via client-side scripting, which means that it is guaranteed not to
work for a considerable number of users. If the login name is actually
obtained from existing information, such as data previously supplied by
the user, then there's no reason to make it an input field; you can
instead display it as normal content, if it is relevant.

BTW, setting font-size: 90% is a bad idea. Setting the font size to 100%
makes more sense. (It's not a dummy setting, since browsers generally
have a reduced font size for input fields by default. This is just mad,
since input fields, if anything, should have the font size chosen by the
user - if not larger. Surely people should be able to see what they
type, and reducing the size for esthetic reasons is... arrogant.)
Jan 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mr. B | last post by:
While at first this may seem a simple tast, it has plagued me for a while... What I want to do is to have the background colour of something like a TextBox to change from (say) White to Yellow to...
3
by: Roberto Castro | last post by:
Hello! I have been assigned for the first time an adp Access project and so far I have managed to make the changes needed for some requirements. However, I am struggling to find the place where...
3
by: Steve | last post by:
I have windows form with the few TextBox controls. Under certain conditions I disable or enable this controls by setting Enable property to true or false: For example: this.m_txtIP.Enabled =...
3
by: A.M | last post by:
Hi, Even I specifically mentioned "white" as background color of all ASP:TextBoxes of my form, Some of them come up with yellow background. I guess it should be kind of ASP.NET behaviour, but...
1
by: slyi | last post by:
Hi All, Does anyone use vml to force the printing of background-colors in IE clients? Regards, slyi eg: <html xmlns:v="urn:schemas-microsoft-com:vml" >
11
by: dgk | last post by:
Is there a way to change the foreground or background color of a single cell in an unbound datagridview?
3
by: bulwark_jrm | last post by:
I'm trying to duplicate functionality found in a Windows application at one of my clients. Essentially, another programmer was able to arrange a lot of search options into a single dialog box by...
1
by: da5namroi | last post by:
One of my my textboxes has a nice white background when running on an XP machine, but becomes dark blak when running on a Vista. Does anybody know how I can fix this? Thank you.
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
0
by: ton | last post by:
Hi, I have an Image which is dark grey/black, at the top a white line, at the left site a white line as well. At 192 px from the left of the screen I position a DIV with this image as the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.