Overwrite background-color (css) - css

I have an input that has two classes with background-color that I need to overwrite. I'm trying to do this: put that input in a external container, and (with javascript) I will change the class of that container to the desire one.
The input has two classes as I said, and those classes are the one which I need to change: irs-line and irs-bar. Those two classes has their own background-color's. I need them on red and yellow. I will trigger the change of classes via javascript with the value of some radio buttons. (that's another story)
My question is, in some forum, a guy give me this hint:
.container.color-yellow .irs-line {
background-color: yellow;
}
.container.color-red .irs-line {
background-color: red;
}
But I'm not sure how it works or how I should use those classes in the input. Any help? (I would ask to that guy what were trying he to do but I can't)
UPDATE:
This is my code where I call the input:
<div className="uk-width-1-4">
<input type="text" name="timewmsslider" ref="timewmsslider" />
</div>
It's Reacjs, so with ref="timewmsslider" is how the input is defined with their default irs-bar and irs-line classes.
That input is being generated with the default irc-line and irc-bar css classes. So, how should I call if I have this classes in the css (for both colors red and yellow)?
.irs-line-yellow {
height: 16px;
top: 24px;
border-radius:8px;
border: #EEEEEE 1px solid;
background: #e9d759; /* Old browsers */
background: -moz-linear-gradient(top, #e9d759 0%, #e9d759 70%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #e9d759 0%,#e9d759 70%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e9d759 0%,#e9e459 70%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e9d759', endColorstr='#e9d759',GradientType=0 ); /* IE6-9 */
position: relative;
display: block;
overflow: hidden;
outline: 0!important;
}
.irs-bar-yellow {
height: 16px;
top: 24px;
margin-left: -7px;
padding-right: 5px;
background: #e9d759; /* Old browsers */
background: -moz-linear-gradient(top, #e9d759 0%, #e9d759 70%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #e9d759 0%,#e9d759 70%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e9d759 0%,#e9d759 70%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e9d759', endColorstr='#e9d759',GradientType=0 ); /* IE6-9 */
position: absolute;
display: block;
left: 0;
width: 0;
border-radius:8px;
border: #EEEEEE 1px solid;
}
.irs-bar-red {
height: 16px;
top: 24px;
margin-left: -7px;
padding-right: 5px;
background: #e95959; /* Old browsers */
background: -moz-linear-gradient(top, #e95959 0%, #e95959 70%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #e95959 0%,#e95959 70%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e95959 0%,#e95959 70%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e95959', endColorstr='#e95959',GradientType=0 ); /* IE6-9 */
position: absolute;
display: block;
left: 0;
width: 0;
border-radius:8px;
border: #EEEEEE 1px solid;
}
.irs-line-red {
height: 16px;
top: 24px;
border-radius:8px;
border: #EEEEEE 1px solid;
background: #e95959; /* Old browsers */
background: -moz-linear-gradient(top, #e95959 0%, #e95959 70%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #e95959 0%,#e95959 70%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #e95959 0%,#e95959 70%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e95959', endColorstr='#e95959',GradientType=0 ); /* IE6-9 */
position: relative;
display: block;
overflow: hidden;
outline: 0!important;
}
I have to change the input classes with those ones depending on externala actions (some radio buttons will change the color of the bar and line via javascript)
Default case: http://jsfiddle.net/h307fdau/
Red case: http://jsfiddle.net/mxt78oa5/

Considering your latest HTML & CSS fiddle edits, I'd suggest the following jQuery:
1.Keep these CSS classes to best isolate the needed background-color property as you did in the shared fiddle in comments:
.red {background-color: red;}
.yellow {background-color: yellow;}
2.This jQuery will add or remove color classes according to radio input selection & remove any colors if they match "actual" string value on slider:
$range.on("change", function() {
//store slider & radio inputs values
var value = $(".js-range-slider").prop("value");
var radioColor = $(".extra-controls input[type=radio]:checked").val();
//if value matches actual remove colors
if (value == 'actual') {
$(".irs-line").removeClass(radioColor);
$(".irs-bar").removeClass(radioColor);
//prevent bottom line from coloring on slider actual date
$("#escenario-moderado").on("change", function() {
$(".irs-line").removeClass("yellow");
$(".irs-bar").removeClass("yellow");
});
$("#escenario-severo").on("change", function() {
$(".irs-line").removeClass("red");
$(".irs-bar").removeClass("red");
});
}
//else add the default radio input selected color
else {
$(".irs-line").addClass(radioColor);
$(".irs-bar").addClass(radioColor);
//add manually selected radio color
$("#escenario-moderado").on("change", function() {
$(".irs-bar").addClass("yellow");
$(".irs-line").addClass("yellow");
$(".irs-line").removeClass("red");
$(".irs-bar").removeClass("red");
});
$("#escenario-severo").on("change", function() {
$(".irs-line").addClass("red");
$(".irs-bar").addClass("red");
$(".irs-bar").removeClass("yellow");
$(".irs-line").removeClass("yellow");
});
}
});
Working JSFiddle

Related

Setting the background image to html button?

I have below code to set the background image to button.
CSS:
input.hButton{
background-image: url('images/hbutton.png');
height: 21px;
width: 110px;
text-align: center;
color: #696969;
font-family: Arial,Helvetica,sans-serif;
font-size: 11px;
display:block;
}
HTML:
<input type="button" class="hButton" id="customize" value="Customize Table"></input>
Output:
Here when the button text is too long, button is split. How can I get it fixed?
Add
background-size: 100% 100%;
or find your perfect setting here:
http://www.css3.info/preview/background-size/
Btw in your case should be better:
use a gradient
use border-radius for the upper corners
use a thin border
replace your css code background-image property with this one :
background-image: url('images/hbutton.png') top repeat-y;
Hi please use the pure css code.. and remove your older method..
Fiddle:http:http://jsfiddle.net/nikhilvkd/RZ4vV/1/
What's Here?
1-Gradient
2-Border radius
3.border top,right and left
.hButton{
border:solid 1px #0e4f85;
border-bottom:none;
-moz-border-radius:5px 5px 0 0;
-webkit-border-radius:5px 5px 0 0;
border-radius:5px 5px 0 0;
padding:3px;
color:#696969;
background: #f7f5f5; /* Old browsers */
background: -moz-linear-gradient(top, #f7f5f5 0%, #e0dede 50%, #e0dede 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f7f5f5), color-stop(50%,#e0dede), color-stop(99%,#e0dede)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f7f5f5 0%,#e0dede 50%,#e0dede 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f7f5f5 0%,#e0dede 50%,#e0dede 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f7f5f5 0%,#e0dede 50%,#e0dede 99%); /* IE10+ */
background: linear-gradient(to bottom, #f7f5f5 0%,#e0dede 50%,#e0dede 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f7f5f5', endColorstr='#e0dede',GradientType=0 ); /* IE6-9 */
}

Style Facebook share button link

I'm wondering if it's possible to style the share button link. Here's the link I would like to access (nested in Facebook's iframe).
<a class="pluginShareButtonLink" href="/sharer.php?
app_id=XXXXXXXXXXXXXXX&sdk=joey&u=http%3A%2F%2FXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&
display=popup" target="_blank" id="u_0_1"><div class="blueButton blue"><div
class="pluginButton"><div><div class="pluginButtonContainer"><div
class="pluginButtonImage"><button type="submit"><i class="pluginButtonIcon img sp_25oo7a
sx_e52148"></i></button></div><span class="pluginButtonLabel">Share</span></div></div>
</div></div></a>
I've tried to change the style of the class pluginShareButtonLink as follows:
.pluginShareButtonLink:hover{
text-decoration: none;
}
And it's not working. I've also tried to change the style with jQuery but this didn't work either. Can it be done somehow?
Thanks
**You can style the button with this css and you can change the background color to any color you want.**
solution 1 (without gradient background color)
.pluginButtonContainer button{
padding: 10px;
width: 70px;
height: 35px;
background: rgb(255, 70, 70);
border: 0px!important;
border-radius: 2px;
}
solution 2 (with gradient background color)
.pluginButtonContainer button{
padding: 10px;
width: 70px;
height: 35px;
background: #ff3a3a; /* Old browsers */
background: -moz-linear-gradient(top, #ff3a3a 0%, #ff3a3a 49%, #ff402b 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff3a3a), color-stop(49%,#ff3a3a), color-stop(100%,#ff402b)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ff3a3a 0%,#ff3a3a 49%,#ff402b 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ff3a3a 0%,#ff3a3a 49%,#ff402b 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ff3a3a 0%,#ff3a3a 49%,#ff402b 100%); /* IE10+ */
background: linear-gradient(to bottom, #ff3a3a 0%,#ff3a3a 49%,#ff402b 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff3a3a', endColorstr='#ff402b',GradientType=0 ); /* IE6-9 */
border: 0px!important;
border-radius: 2px;
}

how is this border effect achieved best with CSS?

I saw an amazing border effect on a website, and I'm wondering how the effect is achieved best. It's a seperator between navigation items in a vertical list:
I will choose the best answer based on the cross-browser compatibilty (and as non-hacky as possible).
Here you go
You may have to mess with it depending on what you want to put inside you list! If you want to change the color of the glow, you can just alter the colors in the gradient. This is a nice generator, which you probably already knew about.
HTML:
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
CSS:
ul {
list-style: none;
width: 200px;
}
li {
background: rgb(30,30,30);
text-align: center;
height: 40px;
color: rgb(140,140,140);
border-bottom: 1px solid black;
}
li:after {
content: '';
display: block;
position: relative;
top: 41px;
height: 1px;
background: #1e1e1e; /* Old browsers */
background: -moz-linear-gradient(left, #1e1e1e 0%, #757575 50%, #1e1e1e 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#1e1e1e), color-stop(50%,#757575), color-stop(100%,#1e1e1e)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #1e1e1e 0%,#757575 50%,#1e1e1e 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #1e1e1e 0%,#757575 50%,#1e1e1e 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #1e1e1e 0%,#757575 50%,#1e1e1e 100%); /* IE10+ */
background: linear-gradient(to right, #1e1e1e 0%,#757575 50%,#1e1e1e 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e1e1e', endColorstr='#1e1e1e',GradientType=1 ); /* IE6-9 */
}

How to have 2 colors in TD background with CSS

I have an event calendar that made use of CSS to paint the background red, to hilight holidays:
.holiday {
text-align: center;
font-size: 11px;
font-weight: bold;
color: #ffffff;
background-color: #da1030;
border: 1px solid black;
height:20px;
width:20px;
}
For special events, I used purple as the background:
.sp_event {
text-align: center;
font-size: 11px;
font-weight: bold;
color: #ffffff;
background-color: purple;
border: 1px solid black;
height:20px;
width:20px;
}
Things work okay:
This to hilight holiday on 1st of this month
1
This to indicate special event that falls on the 5th of this month
5
BUT there are times that my special event falls on a holiday. So in this case, I want to have the TD background to be painted in red and purple, dividing the TD in 2 equal halves. Could you guys show me how this can be done with CSS? TIA.
You could accomplish this with a pseudoelement in the td that takes up half of the width and is positioned on the right to get the full width/height.
.holiday.sp_event:after {
position: absolute;
width: 50%;
height: 100%;
right: 0;
background-color: red;
content: "";
top: 0;
}
http://jsfiddle.net/rX7gd/
Here is a working fiddle
One solution people use is to use a gradient:
background: #a423b2; /* Old browsers */
background: -moz-linear-gradient(left, #a423b2 0%, #bf24b4 49%, #da1030 50%, #da1030 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#a423b2), color-stop(49%,#bf24b4), color-stop(50%,#da1030), color-stop(100%,#da1030)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #a423b2 0%,#bf24b4 49%,#da1030 50%,#da1030 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #a423b2 0%,#bf24b4 49%,#da1030 50%,#da1030 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #a423b2 0%,#bf24b4 49%,#da1030 50%,#da1030 100%); /* IE10+ */
background: linear-gradient(to right, #a423b2 0%,#bf24b4 49%,#da1030 50%,#da1030 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a423b2', endColorstr='#da1030',GradientType=1 ); /* IE6-9 */
I created this using this tool. It is cross-browser complaint (IE6 up) and requires you to make no structural changes to your HTML at all.

CSS3 Nav Link Backgrounds

I'm trying to have an active state to show the user what page they are on. I created a div class of "nav-active" around and anchor tag as shown below.
<li><div class="nav-active">Blog</div></li>
I did this so that i could make the background dynamic in size based on how many characters the nav-link was.
.nav-active {
background: #ff4b33; /* Old browsers */
background: -moz-linear-gradient(top, #ff4b33 0%, #ca2913 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff4b33), color-stop(100%,#ca2913)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ff4b33 0%,#ca2913 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ff4b33 0%,#ca2913 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ff4b33 0%,#ca2913 100%); /* IE10+ */
background: linear-gradient(top, #ff4b33 0%,#ca2913 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff4b33', endColorstr='#ca2913',GradientType=0 ); /* IE6-9 */
height:70px;
margin-top: -30px;
padding: 0 15px;
because of the padding, depending on what page i'm on the links move.
I'm sure there is a better way about doing this, the question is how?
Any help would be greatly appreciated.
Apply the background to the link style directly, like this:
<li><a class="nav-active" href="index.html">Blog</a></li>
To prevent your links from changing in size depending on what page you are on, style the positioning for all your links and only the background for .navactive:
#nav li {
position: float;
}
#nav li a {
display: block;
padding: 0 15px;
...
}
#nav li a.nav-active {
-webkit-linear-gradient(top, #ff4b33 0%,#ca2913 100%);
...
}

Resources