How to set styles to ng-select box using Scss in Angular4 - html

I have a ng-select field in my HTML, i want to apply some part of css to that, Here i am using scss, i am not getting how to transverse these codes to the class i had given, Can anyone help me to sort it out.
Scss:
.box {
background-color: #4389a9;
width: 185px;
height: 45px;
padding: 8px 20px;
right: -19px;
cursor: pointer;
top: 19px;
transition: bottom 2s;
border-radius: 24px;
margin-bottom: 26px;
select-dropdown {
display: none;
}
}
HTML:
<ng-select class="box" placeholder="Wiredelta" [options]="cities">Wiredelta</ng-select>
CSS part to be added to scss:
ng-select > div > div.single > div.toggle {
color: white !important;
background: none;
}
ng-select > div {
border:none !important
}
ng-select > div > div.single > div.placeholder {
color: white;
font-size: 35px;
font-family: MontserratRegular;
}
ng-select > div > div.single > div.clear:hover, ng-select > div > div.single > div.toggle:hover {
background-color: #4389a9;
}
select-dropdown {
display: none;
}

Note:
If you are using angular cli it wont work if you add in component scss files.
To make it work, add them in styles.scss
Here is the scss you needed,
ng-select {
>div {
>div.single {
>div.toggle {
color: white !important;
background: none;
&:hover {
background-color: #4389a9;
}
}
>div.placeholder {
color: white;
font-size: 35px;
font-family: MontserratRegular;
}
>div.clear {
&:hover {
background-color: #4389a9;
}
}
}
border: none !important;
}
}
select-dropdown {
display: none;
}

Suppose we want to change the styling of appearance outline :
we can override the css as :
.ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-selected,
.ng-dropdown-panel
.ng-dropdown-panel-items
.ng-option.ng-option-selected.ng-option-marked {
color: #26808a !important;
}
.ng-select.ng-select-focused .ng-select-container:after {
border-color: #26808a !important;
}
.ng-select.ng-select-focused .ng-select-container.ng-appearance-outline:after,
.ng-select.ng-select-focused
.ng-select-container.ng-appearance-outline:hover:after {
border-color: #26808a !important;
}
.ng-select.ng-select-focused
.ng-select-container
.ng-value-container
.ng-placeholder {
transform: translateY(-1.28125em) scale(0.75) perspective(100px)
translateZ(0.001px);
color: #26808a !important;
}
.ng-select.ng-select-focused .ng-select-container .ng-arrow-wrapper .ng-arrow {
color: #26808a !important;
}
.ng-select .ng-select-container.ng-appearance-outline {
min-height: 51px !important;
}
ng-select tag:
<ng-select
[items]="listofBanks"
[(ngModel)]="selectedCity"
bindLabel="firstName"
bindValue="id"
[searchFn]="customSearchFn"
(change)="onSelection($event)"
appearance="outline"
class="custom"
></ng-select>
Note: Works fine with "#ng-select/ng-select": "^5.0.4"

Related

How to change ng-dropdown-panel style in ng-select?

I want to change the ng-dropdown-panel style but its only styles the container.
components.css
.ng-select.dropdown ::ng-deep .ng-select-container {
min-height: 0px;
border-radius: 10;
background-color: #343A40;
color: white;
}
.ng-select.dropdown ::ng-deep .ng-dropdown-panel {
background-color: #343A40;
color: white;
}
component.html
<ng-select class="dropdown" [items]="data" bindLabel="data" bindValue="dbValue"></ng-select>
https://stackblitz.com/edit/angular-stq6ew

Set hover on the link inside a class

I'm trying to set a :hover for a link inside a class. At first I tried
.link{
color: #e62739;
}
I saw past discusssion and try the solution proposed
.opener a.link:hover {
color: #e62739;
}
but it didn't work. Im'not sure to know where is my mistake.
.link{text-decoration:none; color:white;}
.opener a.link:hover {
color: #e62739;
}
.row {
display: flex; /* equal height of the children */
}
.col {
flex: 1; /* additionally, equal width */
padding: 1em;
border: solid;
}
div {font-family:'Varela Round';
}
.opener {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border: 1px white solid;
}
.benefits {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-decoration: none;
display: inline-block;
font-size: 16px;
width:300px;
}
a {
text-decoration: none;
}
#upbutton {
border: 1px dotted white;
}
<div class="row">
<div class="opener col" style="padding-left: 10px;padding-right: 10px;"><a class="link" href="www.google.com" name="1" onclick=" show('1');" style="color: white;font-size: 14px;">SOCIETES: 400</a>
<div class="benefits" id="b1" style="display: none; color: white; font-size: 14px;">Part SBF 120 : 120<br />
Part Filiales +100M€: 280
<div id="upbutton"><a onclick=" hide('1');">fermer</a></div>
</div>
</div>
The issue is the inline styling you've got on the link: color: white;.
This is taking priority over any styling you're adding in your CSS file. Removing that from the inline styling allows the hover color to work.
If you need the white color by default add it to the stylesheet rather than inline. For example:
.link {
color: white;
}

CSS class not applying to

I want to apply the CSS class washes_times_links to the html below, but for some reason it's not working.
.washes_times_links a {
display: block;
padding: 15px;
padding: 13px;
text-align: center;
color: #3b524b;
font-size: 15px;
text-transform: capitalize;
}
.washes_times_links a:nth-child(odd) {
background-color: #fff;
}
.washes_times_links a:last-child {
border-radius: 0 0 5px 5px
}
.washes_times_links a:hover {
color: #fff;
background-color: #12be9c;
}
<p class="washes_times_links">
1 time a week
2 times a week
</p>
It looks fine.
Inspect on the css attributes in this: [https://jsfiddle.net/nf0a5gq7/][1] and you will see that all css attributes have been applied, but you're missing 'border' attribute (in .washes_times_links a:last-child), and this is why you can't see the border..
Generally speaking in a way to be useful for whoever cross by here.
To apply style in odd/even selector:
.class_name a:nth-child(odd) {
background-color: #ffff99;
}
.class_name a:nth-child(even) {
background-color: #b8d1f3;
}
To apply radius/style for first/last selector:
.class_name a:first-child {
border-radius: 5px 5px 0 0;
}
.class_name a:last-child {
border-radius: 0 0 5px 5px;
}
all together :
HTML
<p class="class_name">
1st row
2nd row
3rd row
4th row
</p>
CSS
.class_name a {
/* default links styles */
}
.class_name a:nth-child(odd) {
background-color: #ffff99;
}
.class_name a:nth-child(even) {
background-color: #b8d1f3;
}
.classname a:first-child {
border-radius: 5px 5px 0 0;
}
.class_name a:last-child {
border-radius: 0 0 5px 5px;
}
.class_name a:hover {
color: #fff;
background-color: #12be9c;
}
Tip: How do I ask a good question?

Need white text on my button instead of the orange I have for links

My normal hyperlink color is orange, but I want the hyperlink color in my button to be white and not to be underline. How would I do that?
Also, if I wanted some vertical spacing between the buttons how would I do that?
JSFiddle:
http://jsfiddle.net/huskydawgs/Uka5v/947/
HTML:
<p>Apple is cool</p>
<a class="btn" href="https://www.apple.com/">Get Started</a>
<a class="orange btn" href="https://www.apple.com/">Get Started</a>
<a class="blue btn" href="https://www.apple.com/">Get Started</a>
CSS:
.btn {
text-align: center;
border-radius: 0px;
background-color: #616161;
display: block;
color: #ffffff;
font-size: 15px;
font-family: sans-serif;
text-decoration: none;
line-height: 30px;
width: 138px;
margin: 0 auto;
}
.orange.btn {
background-color: #f66511;
}
.blue.btn {
background-color: #2251a4;
}
a:link {
color:#f66511;
text-decoration:none;
}
a:visited {
color:#f66511;
text-decoration:none;
}
a:active {
color:#f66511;
text-decoration:none;
}
a:hover {
color:#f66511;
text-decoration:underline;
}
You need to use
.orange.btn {
background-color: #f66511;
}
.blue.btn {
background-color: #2251a4;
}
(you were missing the "." infront of orange and blue which states the class.
For the vertical spacing, you can use this css:
.btn {
margin-bottom: 5px;
}
http://jsfiddle.net/Uka5v/940/
You're not defining the variated classes properly. Try this:
.btn.orange {
background-color: #f66511;
}
.btn.blue {
background-color: #2251a4;
}
As for vertical spacing, you can set a bottom margin on the .btn class. Since you already have a margin property, you can simply add to it:
margin: 0 auto 10px; // Added third argument for bottom value
Here's the updated JSFiddle.
EDIT: To change the color of the orange button, set a color property on the corresponding class:
.btn.orange {
background-color: #f66511;
color: #fff;
}
change your css to
.orange {
background-color: #f66511;
}
.blue {
background-color: #2251a4;
}
You just need to use
.orange {
background-color: #f66511;
}
.blue {
background-color: #2251a4;
}
And take a look at margin for adding vertical spacing.
I suggest you brush up on your html knowledge. Try codecademy for interactive tutorials.

How can I align buttons to the center of the navbar

I'm using jQuery Mobile to create this navbar but I can't align the buttons to the center.
Here is my code:
<footer data-role="footer" data-position="fixed" data-theme="b">
<nav data-role="navbar">
<ul>
<li>Record</li>
<li>Upload</li>
<li>Refresh</li>
<li>Clear</li>
</ul>
</nav>
</footer>
I have tried with data-grid="c" but it's not working.
Any idea?
I haven't add any CSS style to this project
This is the compiled jQuery Mobile:
Block (each block inside the navbar):
.ui-grid-c > .ui-block-a, .ui-grid-c > .ui-block-b, .ui-grid-c > .ui-block-c, .ui-grid-c > .ui-block-d {
width: 25%;
}
ul.ui-grid-a, ul.ui-grid-b, ul.ui-grid-c, ul.ui-grid-d, ul.ui-grid-solo, li.ui-block-a, li.ui-block-b, li.ui-block-c, li.ui-block-d, li.ui-block-e {
margin-left: 0;
margin-right: 0;
padding: 0;
list-style: none;
}
.ui-block-a {
clear: left;
}
.ui-block-a, .ui-block-b, .ui-block-c, .ui-block-d, .ui-block-e {
margin: 0;
padding: 0;
border: 0;
float: left;
min-height: 1px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
li {
display: list-item;
text-align: -webkit-match-parent;
}
.ui-navbar ul {
list-style: none;
}
ul.ui-grid-a, ul.ui-grid-b, ul.ui-grid-c, ul.ui-grid-d, ul.ui-grid-solo, li.ui-block-a, li.ui-block-b, li.ui-block-c, li.ui-block-d, li.ui-block-e {
list-style: none;
}
ul, menu, dir {
list-style-type: disc;
}
.ui-bar-b, .ui-page-theme-b .ui-bar-inherit, html .ui-bar-b .ui-bar-inherit, html .ui-body-b .ui-bar-inherit, html body .ui-group-theme-b .ui-bar-inherit {
color: #fff /*{b-bar-color}*/;
text-shadow: 0 /*{b-bar-shadow-x}*/ 1px /*{b-bar-shadow-y}*/ 0 /*{b-bar-shadow-radius}*/ #111 /*{b-bar-shadow-color}*/;
font-weight: bold;
}
.ui-overlay-a, .ui-page-theme-a, .ui-page-theme-a .ui-panel-wrapper {
color: #333 /*{a-page-color}*/;
text-shadow: 0 /*{a-page-shadow-x}*/ 1px /*{a-page-shadow-y}*/ 0 /*{a-page-shadow-radius}*/ #f3f3f3 /*{a-page-shadow-color}*/;
}
.ui-overlay-a, .ui-page-theme-a, .ui-page-theme-a .ui-panel-wrapper {
color: #333 /*{a-page-color}*/;
text-shadow: 0 /*{a-page-shadow-x}*/ 1px /*{a-page-shadow-y}*/ 0 /*{a-page-shadow-radius}*/ #f3f3f3 /*{a-page-shadow-color}*/;
}
body, input, select, textarea, button, .ui-btn {
font-size: 1em;
line-height: 1.3;
font-family: sans-serif /*{global-font-family}*/;
}
Icon
.ui-btn-icon-notext:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after {
left: 50%;
margin-left: -11px;
}
.ui-btn-icon-notext:after, .ui-btn-icon-left:after, .ui-btn-icon-right:after {
top: 50%;
margin-top: -11px;
}
.ui-btn-icon-left:after, .ui-btn-icon-right:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after, .ui-btn-icon-notext:after {
content: "";
position: absolute;
display: block;
width: 22px;
height: 22px;
}
.ui-btn-icon-left:after, .ui-btn-icon-right:after, .ui-btn-icon-top:after, .ui-btn-icon-bottom:after, .ui-btn-icon-notext:after {
background-color: #666 /*{global-icon-color}*/;
background-color: rgba(0,0,0,.3) /*{global-icon-disc}*/;
background-position: center center;
background-repeat: no-repeat;
-webkit-border-radius: 1em;
border-radius: 1em;
}
All you need is, to force button inside each block to fill width completely.
.ui-navbar li a {
width: 100% !important;
}
Demo
You may want to look at using vertical-align
The vertical-align CSS property specifies the vertical alignment of an
inline or table-cell box.
Try:
a.ui-btn{
vertical-align:middle;
}
Although this is on the assumption you dont have other style settings which may interfere, its hard to say without having your CSS. You may need to also set margin:0; or remove any paddingfrom the containing li
Try margin: 0 auto in your css