Combine CSS styles applied to ASP controls - html

I am using DevExpress controls on ASP Web Forms Application. I would like to have different disabled styles for my buttons, so I've created some styles:
.dxmLite_Moderno .dxm-disabled, .dxmLite_Moderno .dxm-disabled a.dx {
color: rgb(1, 211, 211);
border-style: none !important;
height: 36px;
padding-top: 2px;
}
.red {
color: rgb(255, 0, 0) !important;
}
.blue {
color: rgb(0, 255, 0) !important;
}
First override style of button if it's disabled.
Second is overriding buttons which have:
<dx:MenuItem ItemStyle-CssClass="red" Text="D" ItemStyle-Width="104" Name="I">
ItemStyle-CssClass called 'red'.
Now question is - it's possible to combine those css styles in way:
if button is disabled and red => have style red
if button is enabled and red => I dont want any style
if button is disabled and blue => have style blue
if button is enabld and blue => I don't want any style
I am asking because now situation looks like if I have enabled / disabled button red it's always color of style red.

What is important you have wrong blue definition color.
Second remove any !important from css.
And finally combine dxm-disabled class with your colors class:
.dxmLite_Moderno .dxm-disabled.red {
color: #f00;
}
.dxmLite_Moderno .dxm-disabled.blue {
color: #00f;
}
I create the demo for you:
http://jsfiddle.net/YQG9B/1/

Related

Remove "!important" coming from bootstrap

I want to override .text-primary with a color of my choice.
So in my override file, I defined it like:
#include text-emphasis-variant(".text-primary",$brand-primary, true);
The text-emphasis-variant is a mixin from Bootstrap 4 that is defined in such a way that the color property is marked as !important. So the generated css file is as follows:
.text-primary {
color: #007bff !important; }
a.text-primary:hover, a.text-primary:focus {
color: #0056b3 !important; }
.text-primary {
color: #0078D2 !important; }
a.text-primary:hover, a.text-primary:focus {
color: #004c86 !important; }
Now, I want to use the text-primary class inside another class:
<div class="customRow">
<span class="text-primary"> Testing </span>
</div>
And I have another override like:
.customRow>span {
color: #555
}
The problem here is that it is not taking the color #555 since the color in text-primary is marked as !important.
i'm currently working on a project that i overrided the bootstrap 5 by following this tutorial hope it can help you too .
if you are using Bootstrap 5 The right way to override $theme-colors is to by doing this
// First override some or all individual color variables
$primary: #25408f;
$secondary: #8f5325;
$success: #3e8d63;
$info: #13101c;
$warning: #945707;
$danger: #d62518;
$light: #f8f9fa;
$dark: #343a40;
// Then add them to your custom theme-colors map, together with any additional colors you might need
$theme-colors: (
primary: $primary,
secondary: $secondary,
success: $success,
info: $info,
warning: $warning,
danger: $danger,
light: $light,
dark: $dark,
// add any additional color below
);
for more information see this link
Add this to your SCSS file.
$enable-important-utilities: false;
source https://getbootstrap.com/docs/5.0/utilities/api/#importance

How are themes implemented in CSS

I am currently using variables keeping track of colors for both light and dark themes (e.g. --light-background-color, --dark-background-color). This isn't too hard with two themes but seems a bit manual and if faced with more themes it becomes impractical.
I have seen things like night shift that apply CSS filters which invert the colors on a webpage. How do these filters work? and how would I go about implementing them?
One way to go about this is to have a set of general theme color variables, rather than specific color variables for specific themes like you're trying to do here.
You can define these variables in the body element and override them with the class or a custom attribute of the body.
Use these variables as you would normally for your other HTML elements, and just change the attribute of the body element to apply a different theme.
The important part here is to make sure your theme color variables have corresponding contrasting color variables as well, so that things like white text on a dark background can swap to dark text on a white background.
Here's an example, where primary and secondary theme and contrast colors are defined in the body element, and are overridden when the body has the "dark" class applied to it:
document.querySelector("button").addEventListener("click", () => document.body.classList.toggle("dark"));
body {
--color-primary: #b4e9ce;
--color-primary-contrast: #000000;
--color-secondary: #308d43;
--color-secondary-contrast: #ffffff;
/* Other theme colors... */
}
body.dark {
--color-primary: #202d26;
--color-primary-contrast: #ffffff;
--color-secondary: #8f8f8f;
--color-secondary-contrast: #000000;
/* Other theme colors... */
}
button {
padding: 10px;
margin-bottom: 20px;
}
.wrapper {
padding: 20px;
background-color: var(--color-primary);
border: solid var(--color-secondary) 10px;
}
.wrapper h1 {
font-family: sans-serif;
text-align: center;
color: var(--color-primary-contrast);
}
<body>
<button>Toggle Theme</button>
<div class="wrapper">
<h1>Hello World</h1>
</div>
</body>
Single Line CSS will change Light Theme to Dark:
<style>
body
{
filter: invert(1);
}
</style>

how to change action button color in matsnackbar?

I'm using snackbar in my Angular 9 project but some reason I'm getting the same background and text color for action button. I added css style in the component.scss file and also global style.scss file but still not working.
this._snackBar.open(`Chart has been copied to ${workspace.name}`, 'Check it out!',
{ duration: 5000, panelClass: "blue-snackbar"}).onAction().subscribe(() => {})
I also tried like this
panelClass: ['my-snack-bar', 'button-bar']}
I also add this in styles.scss and component.scss file but still not working
.my-snack-bar {
background-color: #E8EAF6;
color: red;
}
.button-bar {
background-color: pink;
color: blue;
}
example
Not sure why it's happening..any suggestion or help will be really appreciated.
In your global styles file, usually styles.scss you need to target the panelClass property, something like this:
.my-snack-bar {
background: #2196F3;
button {background:white; color: blue}
}
Here's a working example https://stackblitz.com/edit/angular-stacb4-b1fuu5

Can't remove button border after click, and it's color does not change

I have virtually zero experience with HTML and CSS, and I'm trying to create a simple website.
I have buttons from Bootstrap, what I'm trying to achieve is, when a button is pressed, it's text would change it's color and will have no border.
This is what I tried:
.btn-secondary:active, .btn-secondary:focus {
color: aquamarine;
outline: none !important;
}
But that does not work.
This is the result:
The change in color does work, but I just can't remove this grey border. I tried looking in Bootstrap docs, but couldn't find anything.
Tried few different things too (such as outline-style etc.) but still, it remains the same.
Try border style like below code -
.btn-secondary:active, .btn-secondary:focus, .btn-secondary:hover {
color: aquamarine;
border: 0 !important;
}
You can use:
.btn-secondary:active, .btn-secondary:focus {
color: aquamarine;
outline: 0;
-moz-outline-style: none;
}
EDIT: CSS supports focus pseudoclass but it's not supported in all browsers. In couple of years when :focus is more supported pure CSS solutions are great but in this time and place I would highly recommend to use JS.
EDIT part 2: changed let to var.
EDIT part 3: Added support for multiple buttons.
This code includes some JS.
<style>
button {
border: 1px solid black;
color: white;
font-size: 18px;
}
.buttonClicked {
border: 0;
}
</style>
<script>
var clickedButtons = [];
function onButtonClick(buttonsId) {
var button = document.getElementById(buttonsId);
if (clickedButtons.includes(buttonsId)) {
button.className = '';
clickedButtons.splice(clickedButtons.indexOf(buttonsId), 1);
} else {
button.className = 'buttonClicked';
clickedButtons.push(buttonsId);
}
}
</script>
<button id="button1" onclick="onButtonClick('button1')">
Button 1
</button>
<button id="button2" onclick="onButtonClick('button2')">
Button 2
</button>
<button id="button3" onclick="onButtonClick('button3')">
Button 3
</button>
<button id="button4" onclick="onButtonClick('button4')">
Button 4
</button>

How to change the text color and background color of ant-tooltip component

I implemented antd tooltip but need to change the background color and text color of it but I am unable to achieve that. I tried to do using "overlayStyle" provided by antd tooltip component but no luck not working as expected. As Shown below.
<Tooltip
title={jobNumber * 3}
placement="bottomRight"
overlayStyle={{
color: "orange",
background: "blue",
}}
>
<div style={{ maxWidth: `${jobNumber * 3}px` }} />
</Tooltip>;
I tried inspecting it but unable to do so as its work on hover and till the time I move my cursor to class but no help.
What I founded on hover the div added one class named 'ant-tooltip-open' but what's that in the class I can't see.
You can do this easily, see below code
.ant-tooltip-inner {
color: yellow;
background-color: green;
}
.ant-tooltip-placement-bottom .ant-tooltip-arrow, .ant-tooltip-placement-bottomLeft .ant-tooltip-arrow, .ant-tooltip-placement-bottomRight .ant-tooltip-arrow {
border-bottom-color: green;
}
here is working demo https://codepen.io/anon/pen/JVvyGr
I hope this can useful for you.
In order to change the color of the ant tooltip arrow use:
.ant-tooltip-arrow::before{
background-color: white;
}
In order to change the color of the arrow use this:
.ant-tooltip-arrow-content{
background-color: #fafafa !important;
}
because it stays as black even when changing the background color of the tooltip and apparently this line of code didn't work for me in Chrome:
.ant-tooltip-placement-bottom .ant-tooltip-arrow, .ant-tooltip-placement-bottomLeft .ant-tooltip-arrow, .ant-tooltip-placement-bottomRight .ant-tooltip-arrow {
border-bottom-color: green;
}