Is there a way to only style the selected option? [duplicate] - css

This question already has answers here:
How to style the option of an html "select" element?
(21 answers)
How do I style a <select> dropdown with only CSS?
(25 answers)
Closed last month.
Usually when you create a <select> option field and use color to change the color.
This applies only to when the dropdown is clicked upon and is in an active state.
Is it actually possible to change the color of the option that is selected? So if you look at the code, only make the option Apple red that is selected (when another fruit is selected, make that red). However, the colors of the text need to black in the dropdown.
select option {
color: red;
}
<select>
<option>Apple</option>
<option>Banana</option>
<option>Peach</option>
<option>Strawberry</option>
<option>Pineapple</option>
</select>
Since this component is a re-used one, I can not edit the HTML structure of it.
I tried to give the options a color, but this resulted in changed all of the option in the active dropdown and not the item selected.
I also looked up other topics and answers in here but every provided code also changes the color in the active dropdown state or they modify the HTML.

Related

How to wrap text in Button and change Button color on click in Google App Maker?

Haven't coded in years, and started to play around with Google App Maker last week. As the title suggests, I have a couple questions.
I'm trying to figure out if there's a way to dynamically change the color of a button upon click. Right now I have the button changing enabled status to false on click, and using CSS style to change the color of disabled buttons to gray. Is there a way to do this without disabling the button?
Is there a way to wrap text in a button? Right now I am overlaying a Label on the button with the correctly styled font, but would ideally like to have that text be from the Button, as the space the label takes up is not clickable.
Thanks in advance for any help!
add some lines to your page or global styles this
this should let you wrap text.
.app-Button {
white-space: pre-wrap;
}
Say you want to change your button blue when a Boolean value gets changed to "true" in your data source.
add a class to your styles
.blue{
background: blue;
}
then select your button and in the property editor>Display>styles click the drop down and select binding
set the binding to
=#datasource.item.**YourBooleanItem** === true? ['blue']:[]
Clarification there are two steps
Define a CSS class
Add the Class to the "styles" property of
your widget.
The Answer above uses a "binding" but also means that you've got to have an Item with this binding which you may not want.
I wanted a 'decimal' button to be orange when it was active. So on the Page I created a DecimalActive property. I used the onAttach event to set this property to false.
I created a CSS Class (local to the page) named Orange and Normal
.Orange {background:orange};
.Normal {background:white};
Then the following is my onClick
onClick(widget,event)
{
widget.root.properties.DecimalActive = !widget.root.properties.DecimalActive;
widget.styles = widget.root.properties.DecimalActive ? ['Orange'] : ['White'];
}
The challenge was figuring out exactly what AppMaker wanted in the styles []. I don't think it puts applied styles in this array. At least they didn't show up when I console.log(JSON.stringify(widget.styles);
I have verified that this does work (Dec 2019)
I think this answer is clearer and if someone wants to bind it the color change they still can.

How to change color of a button component of an ionic app in appery

I am a newbie in Appery. Can some one tell me the steps to set custom color for a Button component using CSS.
all Appery Buttons are set by CSS, so you have three options
you can choose one of the drop downs when you select the button called Swatch by picking a letter you can select the precoded colors from the drop down based on the theme you are using.
you can create a new css sub sheet and just assign a specific value a color or a specific group of items (all buttons) a color
(I WOULD NOT ADVISE THIS) you can edit the general css sheet for the theme.

Bootstrap 3 Dropdown CSS Colour [duplicate]

This question already has answers here:
Bootstrap 3 - Change dropdown background colour
(4 answers)
Closed 8 years ago.
I have a dropdown pill that turns pink on hover and stays pink when clicked. However if you click it twice and then move the mouse away it turns grey.
It is the "recipient" link in the following example:
Example and code
Why is this? Is there some CSS I can use to overwrite this functionality? I'd rather the background went black again.
This is what I mean:
Thanks
I cant' reproduce your issue with the double click but I can see a gray background with Tab Navigation. Add also the state for the :focus. Try this:
.nav-pills>li>a:hover, .nav-pills>li>a:focus {
background-color: #FF6699;
}
BootplyDemo

input-lg equivalent for checkboxes and radios [duplicate]

This question already has answers here:
How can I change the size of a Bootstrap checkbox?
(10 answers)
Closed 3 years ago.
I am creating a mobile-targeted page using Twitter Bootstrap. Since it's mobile-targeted, I'd like all my form UI elements to be nice and big.
The input-lg class achieves this nicely for ordinary text inputs. But it has no effect on radio buttons or checkboxes, and I don't see an equivalent class for them mentioned in the docs.
How should I achieve the same result for checkboxes and radio buttons?
It is possible via CSS, you can add the class "form-control" to your checkbox or radio button and it will become bigger; input-* classes will not affect the size of the control, only with input-sm you can see a little difference.

Change select color once an option has been selected

I'm trying to change the css color of a select box once an option has been selected. Seems like it would be easy and common but I can't seem to find an answer.
Basically, I am starting out with a dimmed color (#999) on the select and then once the user selects an option it should change to #222 (think of the first option as placeholder text). I'm sure most people will say I need to apply the color to the option but I have tried that and it only works for the options themselves and not the starting color for the box. I've tried javascript and again, it works for the options themselves but not the select color.
You can do that with JQuery. Make a before and after class that looks the way you want. Then switch after the click
$('#Mycontrol').click(function(){
$('#Mycontrol').addClass('MynewClass');
});

Resources