"cursor: pointer" just not working at all - html

This is my angular template code:
<!-- Modal -->
<ng-template #levelsmodal let-c="close" let-d="dismiss">
<div class="modal-header">
Select the levels you want to show in the table and chart
</div>
<div id="segments-modal" class="modal-body">
<div class="row margin" *ngFor="let level of config?.data?.groups; let i = index" (click)="selectLevel(level)">
<div class="colorspan" [style.backgroundColor]="level.active ? colors[i] : 'gray'" class="colorspan">
</div>
<span class="level-labels pointer-cursor" [innerHTML]="getLabel(level)" ></span>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-success" (click)="c()">Close</button>
</div>
</ng-template>
The class "pointer-cursor" is plain simple:
.pointer-cursor{
cursor: pointer !important;
z-index: 500;
}
The z-index was only added for trying if it could make some difference, but it doesn't. I also tried applying this class to other parts like the wrapper div and so, but it's just not working. I keep seeing the normal "text cursor" instead of the pointer one...
Does anybody know why this happens?

Try that
::ng-deep .pointer-cursor{
cursor: pointer !important;
z-index: 500;
}
Edit
The ::ng-deep combinator (https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep) ensures that the defined style applies to all child elements of the component, not only elements directly created by the component.
Since the element you want to style in inside a ng-template tag (so it does not belong directly to the component), you need to use this to style its elements

Related

CSS Selector fails to change style

I have this css code for an Angular mat-group-button
mat-button-toggle-group mat-button-toggle button div.mat-button-toggle-label-content {
line-height: 0px;
}
This is the generated code
<mat-button-toggle-group _ngcontent-sah-c203="" role="group" name="os_attribution" aria-label="Atribuição de OS"
class="mat-button-toggle-group mat-button-toggle-group-appearance-standard" ng-reflect-name="os_attribution"
aria-disabled="false">
<mat-button-toggle _ngcontent-sah-c203="" value="anyone"
class="mat-button-toggle mat-button-toggle-appearance-standard" ng-reflect-value="anyone" tabindex="-1"
id="mat-button-toggle-2"><button type="button" class="mat-button-toggle-button mat-focus-indicator"
id="mat-button-toggle-2-button" tabindex="0" aria-pressed="false" name="os_attribution">
<div class="mat-button-toggle-label-content">
<mat-icon _ngcontent-sah-c203="" role="img" class="mat-icon notranslate material-icons mat-icon-no-color"
aria-hidden="true">assignment_turned_in</mat-icon>
Atribuídas
</div>
</button>
</mat-button-toggle>
</mat-button-toggle-group>
I am able to change the style of the elements until this selection
mat-button-toggle-group mat-button-toggle {
background: red;
}
But after that, when I reach button, nothing I've tried works
What's happening ?
I suppose you're using angular right?
In this case the problem is about view encapsulation.
If you check the generated styles, you notice that they are scoped to the parent components assigned ID.
To opt out of the view encapsulation you can use the ::ng-deep selector.
::ng-deep mat-button-toggle-group mat-button-toggle button div.mat-button-toggle-label-content {
line-height: 0px;
}
You forgot to use the CSS class selector .!
.mat-button-toggle-group .mat-button-toggle {
background: red;
}
If any of those are angular components, you cannot be sure that they will build into the same HTML tag names. Its better to use classes if it involves non-standard tag names (stuff that isn't button, div, span, etc).
mat-button-toggle is missing the period. Needs to be .mat-button-toggle.

How can I change color based on element collapse status?

I would like to set different colors depending on whether the div is collapsed or expanded.
For example: If some section is collapsed, I want to set the background color of my button and header color <h2> to be more muted (to be specific rgb(115, 129, 184);), and when the same section is expanded I want them to be set to my primary color (rgb(54, 74, 153);).
Here's my HTML file:
<section id="category">
<div class="d-flex justify-content-between align-items-baseline">
<h2>Category</h2>
<button class="btn section-dropdown-btn float-right" type="button"
data-toggle="collapse" data-target="#categoryitems" aria-expanded="false">
<i class="dropdown-expanded fa fa-angle-down"></i>
<i class="dropdown-collapsed fa fa-angle-up"></i>
</button>
</div>
</section>
And my CSS (based on this thread: https://stackoverflow.com/a/42291535):
.section-dropdown-btn[aria-expanded=false] .dropdown-collapsed{
display: none;
}
.section-dropdown-btn[aria-expanded=true] .dropdown-expanded{
display: none;
}
.section-dropdown-btn[aria-expanded=false]{
background-color: rgb(115, 129, 184);
}
.section-dropdown-btn[aria-expanded=true]{
background-color: rgb(54, 74, 153);
}
But I don't feel like this is a great and clean solution. Also, only button has that aria-expanded attribute, so my <h2> tag can't easily determine if it's collapsed or not. I would also have to make many similar CSS rules, about one class just to change one attribute.
How can I achieve that and how could I avoid repetitiveness?
Bootstrap puts collapse and show classes on the element when it does its thing. You should be able to target those with your CSS selectors. That doesn't help with your parent element problem, but it's cleaner than using the ARIA attribute.
For the parent selector you can use the available events. Write a function something like this, with a similar inverse function for hide:
$('.item-wrapper').on('shown.bs.collapse', function () {
$(this).closest('h2').addClass('blah');
});
Then you'd use your custom class for all CSS inside that element.

How to set state of an element in div based on the state of other element using css

<div class="ms-OverflowSet commandMenu root-236" role="menubar">
<div class="ms-OverflowSet-item item-237">
<button type="button" class="ms-Button ms-Button--commandBar commandMenu-item root-239" data-is-focusable="true" tabindex="-1">
<div class="ms-Button-flexContainer flexContainer-119">
<i data-icon-name="Edit" class="ms-Button-icon icon-241" role="presentation" aria-hidden="true"></i>
</div>
</button>
</div>
<div class="ms-OverflowSet-overflowButton overflowButton-238">
<button type="button" class="ms-Button ms-Button--commandBar commandMenu-overflowitem root-239" aria-label="More" data-is-focusable="true" aria-expanded="false" aria-haspopup="true" tabindex="-1">
<div class="ms-Button-flexContainer flexContainer-119">
<i data-icon-name="MoreVertical" class="ms-Button-menuIcon menuIcon-242" role="presentation" aria-hidden="true"></i>
</div>
</button>
</div>
</div>
By default "ms-Button ms-Button--commandBar commandMenu-item root-239" and are hidden "ms-Button ms-Button--commandBar commandMenu-overflowitem root-239"
I want to set state of both of them to visible if .commandMenu-overflowitem aria-expanded value is true "true"
.commandMenu-overflowitem[aria-expanded="true"]{
visibility: visible;
display: flex
}
Above is working to set state of commandMenu-overflowitem
Similarly, I tried to set state of commandMenu-item as below, but it doesn't work
.commandMenu-overflowitem[aria-expanded="true"] .commandMenu-item{
visibility: visible;
display: flex
}
You can't do that with css only. You need JS. This question came up on the REACT questions list. Is related to REACT?
If is ReactJs, you will set a value in the state based on the first div and check for this state in the second div. Depending on the value you can show a different class. The way you are describing the problem is a bit confusing. Setting the state of a div..I assume is changing the class of a div based on an another div class..or whatever value you will save in state.

Angular - Primeng's confirmDialog is shown behind the ng-bootstrap's modal

I'm using the primeng and ng-bootstrap components to make a website with angular.
To capture information I use a form within an ng-bootstrap modal. When clicking on the "save" button of that modal The primeng confirmDialog should appear. The problem is that it appears behind the modal.
How can I fix it?
Here's some of my HTML:
<p-confirmDialog header="Confirmation" icon="pi pi-exclamation-triangle" width="425" appendTo="body"></p-confirmDialog>
<ng-template #modalFormOrder let-c="close" let-d="dismiss" id="modalFormOrder">
<div class="modal-header">
...
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" (click)="c('Close click')">Close</button>
<button type="button" class="btn m-btn--pill m-btn--air btn-success" (click)="SaveEditLoadOrder()">Save</button>
</div>
</ng-template>
I'm somehow sure that both dialogs use z-index CSS property
Override the z-index CSS property with a bigger number for the element that you want to appears first, example z-index: 1001;
If you want to override Css for PrimeNG I suggest you write it on /src/styles.css . Following Example is overriding calendar CSS
.ui-calendar {
width: 100%;
height: 100%;
}
On PrimeNG documentation you can find the CSS classes to override for each component

Zocialcss CSS button background changes to white.

I am trying to incorporate ZocialCSS buttons in my site but the color of the background changes automatically to white when I insert them instead of retaining the rest of the buttons default color.
<div className="form-group">
<div className="col-sm-offset-2 zocial facebook">
<button class="zocial facebook">
Sign in with Facebook
</button>
</div>
</div>
I works in JSFiddle: http://jsfiddle.net/Bc6Et/, but in my computer, the class part is ignored, so I just get a plain HTML button.
Here is a picture of what it looks like when I write the zocial facebook within the className part:
Everyone is saying I should use class instead of className, but it gets ignored wherever I substitute it. Does anyone know why?
Additional comments
I am using React.
I have a index.html file that calls a js file, containing a render function with the above HTML code in it.
ANSWER
Incluiding className within button worked perfectly:
<div className="form-group">
<div className="col-sm-offset-2">
<button className="zocial facebook">
Log in with Facebook
</button>
</div>
</div>
You need your CSS to affect the <button> within your <div>.
Also, it should be class instead of className
<div class="zocial facebook">
<button>Log in with Facebook</button>
</div>
CSS:
.zocial.facebook button {
background-color: #somecolor
}
Or simply put the same class to the button as well as the div:
<div class="zocial facebook">
<button class="zocial facebook">Log in with Facebook</button>
</div>
First you should use "class=" not "className="
If background color is still imported after correcting, you can do the following:
you can override css by adding element styles
<div class="zocial facebook" style="background: none">
or
<div class="zocial facebook" style="background-color: rgba(0, 0, 0, 0);">
you can also rewrite the css for .zocial facebook by targeting it in a style tag
<style>
.zocial facebook {background: none; background-color: rgba(0,0,0 0);}
</style>
ANSWER Incluiding className within button worked perfectly:
<div className="form-group">
<div className="col-sm-offset-2">
<button className="zocial facebook">
Log in with Facebook
</button>
</div>
</div>