I use several menus for my app and I use angular material mat-menu component for this. I can change the style of all menus by writing css code in my global css file for menu original classes. but when I want to add some specific styles to one of them using .custom-class-name .original-material-class-name{} it doesn't apply those styles to that one menu.
here's the whole app in stackblitz: app
header.component.html:
<div>
<a mat-button class="theme-menu-toggle-button" *ngIf="!menuAvailable"
(click)="changeSidenavMode(!mode)">
<mat-icon>menu</mat-icon>
</a>
<a href="#" fxHide.lt-md fxShow.gt-sm class="theme-user" mat-button
[matMenuTriggerFor]="menu">
<img src="assets/images/user.png" class="theme-profile-image rounded-circle">
<span class="theme-profile-title">نام نامخانوادگی</span>
</a>
<mat-menu #menu="matMenu" class="profile-menu">
<button mat-menu-item *ngFor="let option of profileOptions">
<mat-icon>{{option.icon}}</mat-icon>
<span>{{option.title}}</span>
</button>
</mat-menu>
styles.css:
.profile-menu .cdk-overlay-pane::before{
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 15px solid #5E35B1;
content: " ";
position: absolute;
top: 10px !important;
animation: fadeInRightBig 0.75s;
}
Simply set whatever class you want on the mat-menu element.
<mat-menu #menu="matMenu" class="providers-menu" xPosition="after" yPosition="below">
...
</mat-menu>
You can style the menu in your component by using ::ng-deep
::ng-deep .mat-menu-panel.providers-menu {
margin-top: 65px;
background-color: #263358;
}
For more information see this github issue:
https://github.com/angular/components/issues/10322
Add custom class in the mat-menu in backdropClass:
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu" backdropClass="custom__menu">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
.custom__menu + * .cdk-overlay-pane > div.mat-menu-panel > div.mat-menu-content {
background-color: #777;
button.mat-menu-item {
color: white;
}
}
Add your stylings to header.component.css, and import it in your page:
#Component({
selector: 'my-selector',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
UPDATE: You need to add !important tags at end of your css tags.
.profile-menu .cdk-overlay-pane::before{
width: 0 !important;
height: 0 !important;
border-left: 8px solid transparent !important;
border-right: 8px solid transparent !important;
border-bottom: 15px solid #5E35B1 !important;
content: " " !important;
position: absolute !important;
top: 10px !important;
animation: fadeInRightBig 0.75s !important;
}
you should use id for html tag and use it in css file
What do you mean?
Related
I have ngx-daterangepicker-material in my angular8 app. It's working fine but it is showing vertically for now. I want to show it horizontally and also want to change the styles of date range picker.
I have this in my component.html
<app-content-overlay [dropshadow]="true" [showArrow]="true" [showArrow]="true" right="-32%" arrowRight="40px">
<ng-template appTemplate="item">
<span class="px-2">Date:
<input type="text"
ngxDaterangepickerMd
[autoApply]="options.autoApply"
[locale]="locale"
[showDropdowns]="true"
startKey="start"
endKey="end"
[(ngModel)]="selected"
[minDate]="minDate"
[maxDate]="maxDate"
[closeOnAutoApply]="options.closeOnAutoApply"
firstMonthDayClass="first-day"
lastMonthDayClass="last-day"
emptyWeekRowClass="empty-week"
lastDayOfPreviousMonthClass="last-previous-day"
firstDayOfNextMonthClass="first-next-day"
[timePicker]="timePicker"
[dateLimit]="dateLimit"
name="daterange" (change)="change($event)" class="border-none p-0"/>
<!-- <span *ngIf="filter?.techs?.selected?.length === 0">{{filterTitle?.techs?.all}}</span>
<span
*ngIf="filter?.techs?.selected?.length === 1">{{helperService.firstNameAndLastInitial(filter?.techs?.selected[0].name)}}</span>
<span *ngIf="filter?.techs?.selected?.length > 1">Multiple</span> -->
</span>
</ng-template>
</app-content-overlay>
But it's showing like this
i tried to change styling of this daterangepicker like this in component.scss
.md-drppicker{
top: 37px !important;
left: -98px !important;
right: auto !important;
width: 500px !important;
}
But my styling is not overriding the default styling. how can i do that?
This works, at least for now, before ng-deep goes away
::ng-deep {
ngx-daterangepicker-material {
& {
.md-drppicker {
min-width: 640px !important;
top: 45px !important;
&.double {
.calendar {
td {
&.active {
background-color: ........;
border-radius: ........;
color: ...........;
&.off {
background-color: ........ !important;
border-color: ....... !important;
color: ........ !important;
}
}
}
.....
I have a list of buttons that look like this:
<button class="PatientImage-button"> <img src="1"> </button>
<button class="PatientImage-button"> <img src="2"> </button>
<button class="PatientImage-button"> <img src="3"> </button>
<button class="PatientImage-button active"> <img src="4"> </button>
<button class="PatientImage-button"> <img src="5"> </button>
And the highlighting is done through a css style border-color: #000000.
Clicking the button calls an event which updates the button's class to include active. Also hovering and focusing on the button should do that too.
I'm trying to get the sass selectors correct so that I don't have to write border-color: #000000 twice in the file. Here's what works:
.PatientImage {
&-button {
padding: 2px;
&:hover, &:focus {
border-color: #000000;
}
}
}
.active {
border-color: #000000;
}
Is there a way with Sass selectors I can do something like this? (doesn't work)
.PatientImage {
&-button {
padding: 2px;
&:hover, &:focus, .active {
border-color: #000000;
}
}
}
Try below code:
.PatientImage-button{
padding: 2px;
&:hover, &:focus,&.active{
border-color: #000000;
}
}
So I'm working on a website for a radio station and have encountered an issue. The range input we use for volume literally refuses to change its background color and height. I'm using SASS (which makes it a scss file type) for the purposes of this project.
I've done some research and have tried a few things the Internet recommended, but unfortunately, none have worked. I have tried using background, background-color and even color fields to try and fix my issue. I have made sure to overwrite everything that might be stopping me from doing so by setting the -webkit-appearance to none.
This is the content of the slider and its parent elements in my hbs file:
<div class="rootplayer">
<div>
<img class="picture" alt='Artist art' src="{{songart}}" width="170px">
<div class="playerinfo">
<p>On air: {{dj}}</p>
<hr>
<p>Up next: AJS Show</p>
<hr>
<p>Currently playing: {{songTitle}}</p>
<hr>
<p>Current Listeners: {{currentListeners}}</p>
</div>
<audio controls="" id="player">
<source src="http://radio.nowhits.uk:8000/radio.mp3" type="audio/mpeg">
<p>Your browser does not support the audio element.</p>
</audio>
</div>
<div class="playercontrols">
<i class="fas fa-play" onclick="play()" id="play"></i>
<i class="fas fa-pause" onclick="pause()" id="pause"></i>
<input type="range" min="0" max="1" value="0.5" step="0.01" class="slider" id="volume">
<script src="scripts/volume.js"></script>
<script src="scripts/playpause.js"></script>
</div>
</div>
And this is the content of the slider object in my scss file:
.slider {
-webkit-appearance: none;
height: 1px;
width: 65%;
background-color: red;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
cursor: pointer;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 12px;
height: 12px;
background: #000;
border-radius: 50%;
}
.slider::-moz-range-thumb {
width: 12px;
height: 12px;
background: #000;
cursor: pointer;
border-radius: 50%;
}
Obviously, the expected output should be a red background and a height of 1px (should be a pretty thin line), but instead, I get this.
Try to add this :
.slider::-webkit-slider-runnable-track {
background: red;
}
.slider::-moz-range-track {
background: red;
}
.slider::-ms-track {
background: red;
}
Look at this site for more customizations : http://danielstern.ca/range.css
I have two buttons at the centre of my page with this css design.
button{
outline: none;
text-align: center;
border-radius:15px 50px 30px;
}
.button:hover {background-color: #3e8e41}
.button:active{
background-color: #3e8e41;
box-shadow:0 5px #666;
transform:translateY(4px);
}
#javaBtn{
color: #fff;
box-shadow:0 9px #999;
background-color:#2ECC71;
border: none;
padding: 15px 30px;
cursor: pointer;
font-size: 12px;
}
#layoutBtn{
color: #fff;
box-shadow:0 9px #999;
background-color:#2ECC71;
border: none;
font-size: 12px;
padding: 15px 20px;
cursor: pointer;
}
My html:
<div align="center">
<img src="yalda.jpg" class= "mainPic">
</div>
<div align="center">
<button class="button" id="layoutBtn">Layouts</button>
<button class="button" id="javaBtn">Java</button>
</div>
<div align="left">
<img src="me.jpg" class= "myPic">
<p><font color="white"> <i>some text</i></font></p>
<a href="&" target="_blank" class="fa fa-linkedin" ></a>
<button class="googleBtn">some text</button>
</div>
I am trying to create another button with a different css design but my third button inherits the css design from the first two and looks kinda like them. What can I do about it?
The third button looks like your first two buttons because you did not create a style that is specific to it. Your first rule applies to all of the buttons on the page:
button {
outline: none;
text-align: center;
border-radius:15px 50px 30px;
}
Unlike your second two rules, here you wrote button and not .button. This means that it will select all elements of type button, not all elements that have class="button".
Additionally, if you want your third button (I am assuming that this is the one with class="googleBtn") to look very different, then you must create a style rule that selects it, like so:
.googleBtn {
color: red;
/* replace this with your style rules */
}
Side note: the HTML align attribute, and the <font> element have been deprecated for years. Please do not use this to format your page.
First, you have to declare a CSS rule for .googleBtn with different styles in the rule. Also I noticed that the two rules in your CSS, #layoutBtn and #javaBtn, styles are exactly the same. Instead, you can define one rule for both #layoutBtn and #javaBtn with that style of button and another for .googleBtn.
Is there a way to make the background of an ionic 2 <ion-item> be transparent?
I have tried this CSS but it doesn't make the item transparent:
.list .item, .item-content .item-inner .item-block .item-ios
{
background: transparent !important;
}
ADDED CODE
My HTML looks like this:
<ion-content class="pu-my-plans-background">
<div *ngIf="hasPlans">
<ion-list no-lines class="pu-item-list">
<!--<ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)">-->
<ion-item-sliding *ngFor="let plan of plans; let i = index" >
<ion-item class="pu-section-list-item pu-my-plans-item" (click)="editPlan(plan.id, plan.rev, plan.title, i)">
{{ plan.title }}
<br>
<span class="pu-my-plans-plan-date">{{ plan.updated}}</span>
<button *ngIf="plan.important" ion-button clear item-right>
<ion-icon name="ios-alert-outline"></ion-icon>
</button>
</ion-item>
<ion-item-options side="right">
<button ion-button color="danger" (click)="deletePlan(plan.id, plan.rev)">
<ion-icon name="delete"></ion-icon>
Delete
</button>
</ion-item-options>
</ion-item-sliding>
<!--</ion-item-group>-->
</ion-list>
</div>
</ion-content>
And my CSS like this:
page-my-plans {
}
.pu-my-plans-plus-circle {
display: block;
//border: 2px solid white;
background-color: $pu-orange;
border-radius: 50%;
height: 38px;
width: 38px;
}
.pu-my-plans-plus-circle span {
font-size: 38px;
font-weight: 100;
color: white;
position: absolute;
top: -7px;
left: 8.5px;
}
.pu-plan-addButton {
font-size: 30px;
margin-right: 14px;
margin-top:-2px;
}
.pu-section-list-item{
color: white;
background-color: black;
font-weight:$pu-item-font-weight;
font-size:$pu-item-font-size;
padding-left:20px;
padding-right:0px;
}
.item{
background: transparent !important
}
// THEMING CSS
// ===========
//
.pu-my-plans-background {
background-image: url("../assets/img/my_plan_bg#2x.png");
background-size: cover !important;
}
.pu-my-plans-item {
border-style:solid;
border-bottom-width: 2px;
border-bottom-color: $pu-orange;
}
.pu-my-plans-plan-date {
color: $pu-orange;
font-size: 11px;
font-weight: 200;
}
I have tried every combination of styling the ionic 2 items as I can think of but the best I can get with this is to get a white background behind the ion-item. The ion-content has an image background but I can't get to see this through the ion-item.
Here is a solution in Ionic 4:
HTML:
<ion-list class="bg-transparent">
<ion-item color="none" lines="none">
Some random text
</ion-item>
<ion-item color="none" lines="none">
Some random text
</ion-item>
</ion-list>
CSS:
.bg-transparent {
background: transparent;
}
Important things to note:
Set background color of the main list to transparent by applying the class and adding CSS as shown.
Add the color="none" attribute to each of the ion-item.
lines="none" remove the lines under each of the ion-item
That should do it!
For Android
.item-md {
background: transparent;
}
For iOS
.item-ios {
background: transparent;
}
Try this in Ionic 5 using CSS Custom Properties.
For ion-item
ion-item {
--ion-item-background: transparent;
}
For ion-list
ion-list {
--ion-item-background: transparent;
}
For the ionic 2 item sliding background color you can change the main sass variable
$item-ios-sliding-content-background(transprent);
$item-md-sliding-content-background(transprent);
In your src -> theme -> variables.scss file
you can find all the variables here
You are using sliding item. Try using the below code
.pu-item-list ion-item-sliding{
background: transparent !important;
}
Try this:
<ion-item color="transparent">
</ion-item>
This worked for me.
ion-item {
--ion-item-background: transparent;
box-shadow: none !important;
}
ion-list {
--ion-item-background: transparent;
box-shadow: none !important;
}
Create a new variable in variable.scss like this:
--ion-color-transparent: rgba(0, 0, 0, 0.0);
and use it like this:
<ion-item color="transparent" padding="0px"><ion-input type="email" placeholder="username"></ion-input></ion-item>.