473,574 Members | 5,352 Online
Bytes | Software Development & Data Engineering Community
+ 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="myRowCla ss">
<td align="right">A ccount Username</td>
<td align="left">
<div id="loginMsg" name="loginMsg" ><input
style="color:re d; 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 11463
la***********@z ipmail.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:re d; 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
2452
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 White to Yellow and then back to White in about 1 second or so. This is to create something like a 'flash' (or a Pulse) for when a User clicks...
3
8801
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 the application changes the color of the background of a textbox. Here the explanation goes: This is a form bound to an SQL view. The detail...
3
1968
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 = false ; The controller become disabled, and I can't enter any data. The problem is that the background color of the TextBox doesn't change whether it...
3
3621
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 I don't know what exactly it means. What is the meaning of that yellow BG color of ASP:TextBoxes ? How can I have control over it?
1
2172
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
109587
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
3180
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 positioning the descriptive label behind the textbox instead of beside it. When the user enters text, the label disappears and the user types in...
1
1857
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
36876
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) { txtDummie.BackColor=Color.Red; }
0
2699
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 background image. In the code I've added a multi line textbox (in my real world it is a treeview). It is placed that I would have to scroll to see the...
0
7826
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7741
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7838
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8126
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5328
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3763
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2257
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1090
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.