label background and foreground change Unexpectedly - asp.net

In my web applicaton I have some div that contain labels, when I click on a label it's foreground become blue and background become white.how can I prevent that?

I would avoid disabling user select colours. I don't know about other people but I often select text on websites, not because I want to copy it but because I am struggling to read it and selecting text is by far the easiest way to change the colour of text against it's background. I even sometimes do it with black text on a white background.

Related

Does Background Color Without Text Matter?

Regarding color contrast:
In this example, do I need to be careful of the blue background even though there is no copy directly on top of it? I.e. do I only need to be concerned with background color when there is copy on top of it, and I could hide the element with the background color from screen readers without causing an issue?
And in this one, do I need to be careful of the contrast between the light blue background and the button or am I only concerned with the contrast between the copy and the button? (I know the image is blurry. It's just an example.)
Both examples are fine as they are.
There are two things that are applicable here.
The first is contrast between text and the background for that text - you must have a contrast ratio of 4.5:1 for normal text and 3:1 for large text / bold text to be WCAG AA compliant. In the first example it is essentially black on white so it will pass easily.
The second is for controls. Buttons, inputs etc. should have a contrast ratio with their background of 3:1 minimum, no matter what state they are in (so if your above button turned white with black text on hover it probably wouldn't pass). In your second example your button is black on light blue so it certainly passes this also.
Also worth noting is that text within controls (your button) has the same 4.5:1 contrast requirement. Yet again white on black passes easily so you are fine.
Just check the contrast (almost certainly fine) on the red button with white text, reds and oranges can be deceiving in their contrast ratios (but as it is quite a dark red I am 99% sure you are fine just by looking at it).
For clarity your blue background in the first one could be 1% darker than the white box and it would be fine as it is not an interactive control that it surrounds.

How to shade text color in TclTk

I implemented a button in TclTk with the text "Click". What I have to do is to write the text with different shades of green.
Is there anyway to make the text' color of a button to be green shaded?
The Tk button makes all of its text be a single colour (controlled by the -foreground option) as that's by far the most important use case for the large majority of users. Making the text vary in colour across its face is outside this use case, and so requires substantial trickery. The two ways I can think of are to use an image instead of a text label (when you can draw whatever you want on it, using the alpha channel to let the background show through) or to use a canvas widget to simulate a button.
Making an image (PNG, or GIF in 8.5 and before) is quite a lot easier.

Highlighting text in JavaFx Label

I am trying to set the text background of the JavaFx label text as green using the following CSS
label.setStyle("-fx-background-color:rgba(85, 255, 68,0.7););
And the unhighlight using the following
label.setStyle("-fx-background-color:rgba(0,0,255,0);");
However these does not work most of the times when it has to be done back to back.
Is there any way to set the style without using CSS i.e. using JavaFx API itself. I found label.textFill(Paint p) for text color but nothing for background colour i.e. the color of the label itself.
Is there any way to set the style without using CSS i.e. using JavaFx API itself.
For some styles (such as the text fill) yes. For background colors, background images, borders, etc API methods will not be available until JavaFX 8 is released (see Public API for Region backgrounds and borders in the JavaFX issue tracker for more information - anybody can sign up for access).
these does not work most of the times when it has to be done back to back.
If you just highlight a label and then unhighlight it again without using something like a PauseTransition to give the user some time to see the highlighted label, then, from the user's perspective nothing is going to happen as all the user will see is an unhighlighted label.
Not sure of your use case, but if you only want to highlight part of the text in a label or let the user highlight the text with a mouse, then you can use a TextField with editable set to false.
Possible Workaround
If the Java 8 preview does not work for you and you are experiencing errors due do bugs in the JavaFX CSS processing, then try placing a Pane then a label inside a StackPane. Set the background color of the Pane to label.setStyle("-fx-background-color:rgba(85, 255, 68,0.7);); Bind the Pane's preferred width and height to the Label's width and height and toggle setVisible on the Pane as appropriate.
Finally I found the workarround. I had to give a PauseTransition to give the system some time between unhighlight and highlight. CSS showed effect only after the pausetransaction if the labels were already highlighted. I think it may be a bug. I will file a jira. The duration of paustransition may be as low as 1 milisecond so that there is not lag from the user's point of view.

Changing stylesheet causes qlabel to move

I have a few labels in a horizontal layout, and I want to enable/disable a border around the labels at certain times. I can do this using stylesheets, but the problem is that every time I enable/disable a border this way, the label shifts left or right in the layout by a few pixels.
This is an annoying artifact that takes away from the look of the UI. Does anyone know how to prevent this from happening?
Thanks!
Marlon
If your labels are on a plain background, then don't enable/disable the borders, just change the border colour to match the background.

Flex text selection: does it have to be white on black?

When you select text in a Text or Label or TextArea (or other) control in a Flex application, the selection is shown in white text on a black background. Always.
I have a request to change that — and it seems to be a simple enough thing to want — but I can't find a style (or property) anywhere that permits that. Any ideas out there about how to do this, or reasons why it definitively can't be done?
Change TextField selection color in AS3
http://ericlin2.tripod.com/select/selectt.html

Resources