CSS class not applying to - html

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?

Related

CSS Text Color not changing

I've been trying to change the color of my text (Normal and Hover) but nothing seems to work. Tried !important but still not showing. Have tried looking at other answers but didn't work.
CSS & HTML Div Code (I have tried removing text-decoration none)
#five {
position : fixed;
top : 10px;
right : 100px;
font-family : monospace;
font-weight : bold;
font-size : 16px;
color : red!;
}
#five:hover {
color : black;
text-shadow : 5px 5px 5px red;
}
<p id="five">
<a href="UNKNOWN" target="_target" style="text-decoration: none;">
TEST5
</a>
</p>
You need to style the a tag, not the parent.
#five a {
text-decoration: none;
color: red;
}
#five:hover a {
color: black;
}
This happens because the <a> tag applies its own color by default (which is a benefit in most cases, but in your case you have to manually change the color directly by using the a selector).
Complete, fixed code:
#five {
position: fixed;
top: 10px;
right: 100px;
font-family: monospace;
font-weight: bold;
font-size: 16px;
}
#five:hover {
text-shadow: 5px 5px 5px red;
}
/* this what I added */
#five a {
text-decoration: none;
color: red;
}
#five:hover a {
color: black;
}
<p id="five">
TEST
</p>
Hi it's because you need to colour the a tag so you could add a class or id to the a tag and then change that.
Change the css to this:
.five {
position: fixed;
top: 10px;
right: 100px;
font-family: monospace;
font-weight: bold;
font-size: 16px;
color: red!;
}
.five:hover {
color: black;
text-shadow: 5px 5px 5px red;
}
And change the html to this:
<p id="five"><a class="five" href="UNKNOWN" target="_target" style="text-decoration: none;">TEST5</a></p>

Put text on the same line with button

I'm trying to put the text with button on right on the same level but for some reason it doesn't show up correctly. What am I doing wrong?
.lyrics {
margin: 20px 0;
}
.lyrics a {
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics a:hover {
text-decoration: none;
color: black;
background: #f0d0b5;
}
lyric-align {
display: inline-block;
margin: 0;
}
Song Title <div class="lyrics">Lyrics
Just write html like this:
<div class="lyrics">Song Title Lyrics</div>
And css like this:
.lyrics {
margin: 20px 0;
}
.lyrics a {
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics a:hover {
color: black;
background: #f0d0b5;
text-decoration: none;
}
And because now you have one div, you can move him where you want. If you want to have a wonder size not across the entire page, but just around the text, use:
.lyrics{
width: fit-content;
width: -moz-fit-content;
}
My recommended solution
I think the best solution would be to do it without DIV, leave only the "a" element there and style it like this. But I don't know what part of the page you didn't show.
HTML
Song Title Lyrics
CSS
.lyrics {
margin: 20px 0;
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics:hover {
text-decoration: none;
color: black;
background: #f0d0b5;
}
Couple of things I see in your code:
A div is a block element, it's going to take up the whole page horizontally where it is placed.
The button is there, you can see it if you hover over the space below the text Song Title. But you don't have a closing tag for the first tag.
Extra Credit
Your CSS for your class lyric-align is missing a dot in front of the class's identifier.
Does this work for you?
I think you want the lyrics to be inline .
.lyrics {
margin: 20px 0;
}
.lyrics a {
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics a:hover {
text-decoration: none;
color: black;
background: #f0d0b5;
}
lyric-align {
display: inline-block;
margin: 0;
}
.lyrics {
display:inline;
}
.song-title {
display:inline;
}
<p class="song-title">Song Title </p><a class="lyrics" href="#">Lyrics</a></div>
If you want a button instead of the link, view this link.

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

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"

Font color is interfering with border color (jsfiddle)

I have a class for a specific font color, and another class for a border color. When I assign an element the class for both, the font color class takes over for both the font and the border.
See example: https://jsfiddle.net/e81jrzfu/
html {
background: #fff;
}
.border-gold {
border-color: #f4cc55;
}
.color-red {
color: #FF0000;
}
.midquote {
display: block;
margin: 1em;
padding: 0.6em;
text-align: center;
border-top: 0.12em dashed;
border-bottom: 0.2em solid;
}
.midquote .icon {
display: block;
margin-top: -1.4em;
}
.midquote i {
background: #fff;
padding: 0 0.6em 0 0.6em;
}
.quoting {
display: block;
}
And the HTML:
<div class="midquote color-red border-gold">
<span class="icon"><i class="fa fa-quote-left"></i></span>
This is an amazing quote from someone.
<span class="quoting">Jon Doe</span>
</div>
This is happening because of the way you've specified your borders in the .midquote rule:
border-top: 0.12em dashed;
border-bottom: 0.2em solid;
These reset the border-color declaration from your .border-gold rule to currentColor, which refers to the color property. This is expected behavior.
You can fix this by using the longhands instead of the shorthands:
.midquote {
display: block;
margin: 1em;
padding: 0.6em;
text-align: center;
border-top-width: 0.12em;
border-top-style: dashed;
border-bottom-width: 0.2em;
border-bottom-style: solid;
}
Or you can rearrange the rules so .midquote comes before all the others (which is probably what you intended).
Your border shorthand rules in your .midquote selector are overriding the style you set with .border-gold. The easiest solution is to either just move the .border-gold after the .midquote rule, or increase the specificity of the .border-gold rule (e.g. div.border-gold).
jsFiddle example (moved rule)
jsFiddle example (increase specificity)
You can just increase specificity of border-gold selector like this .midquote.border-gold or div.border-gold
What is Specificity?
If two selectors apply to the same element, the one with higher specificity wins
html {
background: #fff;
}
.midquote.border-gold {
border-color: #f4cc55;
}
.color-red {
color: #FF0000;
}
.midquote {
display: block;
margin: 1em;
padding: 0.6em;
text-align: center;
border-top: 0.12em dashed;
border-bottom: 0.2em solid;
}
.midquote .icon {
display: block;
margin-top: -1.4em;
}
.midquote i {
background: #fff;
padding: 0 0.6em 0 0.6em;
}
.quoting {
display: block;
}
<div class="midquote color-red border-gold">
<span class="icon"><i class="fa fa-quote-left"></i></span> This is an amazing quote from someone.
<span class="quoting">Jon Doe</span>
</div>
if i understand it correctly you need to add !important for .border-gold for this as follow:
.border-gold {
border-color: #f4cc55 !important;
}
.color-red {
color: #FF0000;
}

How to reuse and override Css style?

ok, here is myResource.css
.gwtCellButton button {
margin: 0;
padding: 5px 7px;
text-decoration: none;
....more styles here...
}
.gwtCellButton button:active {
border: 1px inset #ccc;
}
.gwtCellButton button:hover {
border-color: orange;
color: orange;
}
Now I want to have .gwtCellButtonSmall that is exactly like .gwtCellButton except that it has padding: 1px 2px;
Ofcourse if i do like this, then I can duplicate code:
.gwtCellButtonSmall button {
margin: 0;
padding: 1px 2px;
text-decoration: none;
....more styles here...
}
.gwtCellButtonSmall button:active {
border: 1px inset #ccc;
}
.gwtCellButtonSmall button:hover {
border-color: orange;
color: orange;
}
If I understand your question correctly, you want to have two elements with similar styles with one having different padding.
Is so, you can share styles between the two elements:
.gwtCellButton button, .gwtCellButtonSmall button{
margin: 0;
padding: 5px 7px;
text-decoration: none;
...
}
Then use !important to override the padding for the specific element:
.gwtCellButtonSmall button{
padding: 1px 2px !important
}
Or you could use something like Sass.
You should not need to duplicate any code or, worse, use !important.
This problem can be solved through the use of modifier classes by specifying two classes on each HTML element: a base gwtCellButton class and a modifier class (regular and small in this example).
.gwtCellButton button {
margin: 0;
text-decoration: none;
}
.gwtCellButton.regular button {
padding: 5px 7px;
}
.gwtCellButton.small button {
padding: 1px 2px;
}
Using the !important declaration unnecessarily can lead to specificity issues down the line.
Use !important. The property which has !important overrides the exactly property if there are any other.
So your case,
padding: 1px 2px!important;
Heavily using them causes you some problems sometimes. Thus, do not forget to have a quick look at this summary too.