Display image on a gradient background on hover via css - html

I have this background:
.background:hover {
background: #F4F4F4 url(../images/arrow_down_over.gif) no-repeat right;
}
that I would like to change into a gradient like this one :
.background:hover{
background: -moz-linear-gradient(top, #f4f4f4 0%, #eeeeee 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f4f4), color-stop(100%,#eeeeee)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* IE10+ */
background: linear-gradient(to bottom, #f4f4f4 0%,#eeeeee 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee',GradientType=0 );
} /* IE6-9 */
But I would like to keep the arrow image. I can't find a way to do it. I did try something like this:
background: -moz-linear-gradient(top, #f4f4f4 0%, #eeeeee 100%) url(../images/arrow_down_over.gif) no-repeat right; /* FF3.6+ */
or add this after the gradient properties but without any success.
background: url(../images/arrow_down_over.gif) no-repeat right;
I can't add another class so I have to deal with this CSS. Any idea how to do it?

You may try:
background: url(../images/arrow_down_over.gif), linear-gradient(...);
Multiple backgrounds must be comma-separated rather than space-separated, and they weirdly stack from top to bottom.
Also note that this is not necessarily supported by all browsers.
See http://css-tricks.com/stacking-order-of-multiple-backgrounds/ and https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_multiple_backgrounds for details

Related

Build colour gradation into html

This is the top row (banner) on my website:
#toprow {position: static;top:0px}
I have found the following code, which I believe will enable me to grade the color from dark blue to light blue. Despite many attempts, I have yet to find a way to build it into my banner:
#grad
{
background: -webkit-linear-gradient(rgb(0,102,255), rgb(153,204,255)); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(rgb(0,102,255), rgb(153,204,255)); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(rgb(0,102,255), rgb(153,204,255)); /* For Firefox 3.6 to 15 */
background: linear-gradient(rgb(0,102,255), rgb(153,204,255)); /* Standard syntax (must be last) */
}
Using this tool, you can easily achieve what you want. This will give you cross browsers solution also. See below for your colour gradation given by colorzilla:
background: #0066ff; /* Old browsers */
background: -moz-linear-gradient(top, #0066ff 0%, #99ccff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0066ff), color- stop(100%,#99ccff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0066ff 0%,#99ccff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0066ff 0%,#99ccff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0066ff 0%,#99ccff 100%); /* IE10+ */
background: linear-gradient(to bottom, #0066ff 0%,#99ccff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0066ff', endColorstr='#99ccff',GradientType=0 ); /* IE6-9 */
Now, if you place this code in #grad it suppose that you have an HTML element having id="grad".

How do I make buttons stay active rather than revert to normal state?

I want touchscreen buttons that stay depressed while the page is active rather than revert to normal state.
Is there a simple solution to this?
Ie, you're on the main page, there are three buttons, you press a button, it takes you to the new page and shades a different color.
The code I'm working with looks like this:
HTML:
<input type="button" value="Name" class="Class" onclick="location.href='#';">
CSS:
.class {display:inline;border:solid #000 3px;margin-left:auto;margin-right:auto;padding:10px;font-family: 'helvetica neue', helvetica, arial;font-size:16px;font-weight:600;
color:#fff; -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em; border-radius: 0.5em;
background: #aaa; /* Old browsers */
background: -moz-linear-gradient(top, #636363 0%, #ffffff 4%, #000000 75%, #ffff00 97%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#636363), color-stop(4%,#ffffff), color-stop(75%,#000000), color-stop(97%,#ffff00)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #636363 0%,#ffffff 4%,#000000 75%,#ffff00 97%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #636363 0%,#ffffff 4%,#000000 75%,#ffff00 97%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #636363 0%,#ffffff 4%,#000000 75%,#ffff00 97%); /* IE10+ */
background: linear-gradient(to bottom, #636363 0%,#ffffff 4%,#000000 75%,#ffff00 97%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#636363', endColorstr='#ffff00',GradientType=0 ); /* IE6-9 */
}
.class:active {background: #bababa; /* Old browsers */
background: -moz-linear-gradient(top, #bababa 1%, #636363 69%, #000000 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#bababa), color-stop(69%,#636363), color-stop(100%,#000000)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #bababa 1%,#636363 69%,#000000 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #bababa 1%,#636363 69%,#000000 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #bababa 1%,#636363 69%,#000000 100%); /* IE10+ */
background: linear-gradient(to bottom, #bababa 1%,#636363 69%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bababa', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
}
What i would do is assign some sort off 'active' class to the link (eather on the server side, of by using some javascript), and give it the same styling as your hover state. Something like this:
#menu a:hover, #menu a.active {
background: #[PressedStateColor];
}
You could add the 'active' class with some easy javascript (jQuery) like this:
// when the dom is ready
$(document).ready(function() {
// for each of the links in the #menu
$('#menu a').each(function() {
// if the href of the link matches the one for the current page
if ($(this).attr('href') == window.location.href) {
// add the class 'active' to the link
$(this).addClass('active');
}
});
});
Note that this is not foolproof, it will only work on simple url's. Personally I would go for a server side solution.
To demonstrate, I set up a little fiddle: http://jsfiddle.net/RyHse/

CSS How to multiple background + gradient?

I got this code from css graident generator, which is transparent at the bottom of the gradient
background: -moz-linear-gradient(top, rgba(248,246,247,1) 0%, rgba(248,246,247,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(248,246,247,1)), color-stop(100%,rgba(248,246,247,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8f6f7', endColorstr='#00f8f6f7',GradientType=0 ); /* IE6-9 */
Now I want to add a background on top of the gradient background
background: url('../images/letter_head.png') left top repeat-x, #f8f6f6;
How do I combine them both?
Just prepend the url of the image to each of your rules.
background: url(someurl), -moz-linear-gradient(top, rgba(248,246,247,1) 0%, rgba(248,246,247,0) 100%); /* FF3.6+ */
Alternatively, if you don't feel like adding url(etc) to each of your rules, you could just specify a single background-image rule:
background: -moz-linear-gradient(top, rgba(248,246,247,1) 0%, rgba(248,246,247,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(248,246,247,1)), color-stop(100%,rgba(248,246,247,0))); /* Chrome,Safari4+ */
...
background-image:url("someurl");
CSS
.bg{
width:800px; height:750px;
background: #38BAC9 url(http://www.google.com/logos/2012/india12-hp.jpg) 10% no-repeat;
background:url(http://www.google.com/logos/2012/india12-hp.jpg) center no-repeat, -webkit-gradient(linear, 0% 0%, 0% 100%, from(#57BEED), to(#38BAC9));
background:url(http://www.google.com/logos/2012/india12-hp.jpg) center no-repeat, -moz-linear-gradient(top, #57BEED 0%, #38BAC9 100%);
}​
DEMO
Check this link for more information
http://userinterfacehome.blogspot.in/2012/09/css-multiple-background.html

My CSS styles are not appearing the same in Firefox as they do in Chrome?

My button is Chrome is appearing like this.
This is what I want.
In Firefox, however, it appears like this.
.mainButton_grey {
border: 1px solid BFBFBF;
background: -webkit-linear-gradient(top,#DBDBDB,#D1D1D1);
padding-top:7px;
text-align:center;
cursor:pointer;
width:200px;
height:22px;
border-radius:3 3;
background-color:#0972BD;
font-size:11px;
font-weight:bold;
font-family:Arial;
color:#404040;
}
Jsfiddle here.
Just a word of advice for gradients - if you want as much browser compatibility as possible, add the following (just change the values).
background: -moz-linear-gradient(black, white); /* FF 3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #ffffff)); /* Safari 4+, Chrome 2+ */
background: -webkit-linear-gradient(black, white); /* Safari 5.1+, Chrome 10+ */
background: -o-linear-gradient(black, white); /* Opera 11.10 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff')"; /* IE8+ */
background: linear-gradient(black, white); /* the standard fallback for old browsers */
Syntax explanation here: http://www.impressivewebs.com/css3-linear-gradient-syntax/
And there's an awesome gradient generator here: http://www.colorzilla.com/gradient-editor/
The reason is because you haven't defined the linear gradient with:
-moz-linear-gradient(top, #DBDBDB, #D1D1D1);
The syntax may be a little different; but each browser has a different way to interpret the gradient.
Here is an example of a gradient with each browser:
background: rgb(245,246,246); /* Old browsers */
background: -moz-linear-gradient(top, rgba(245,246,246,1) 0%, rgba(219,220,226,1) 21%, rgba(184,186,198,1) 49%, rgba(221,223,227,1) 80%, rgba(245,246,246,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(245,246,246,1)), color-stop(21%,rgba(219,220,226,1)), color-stop(49%,rgba(184,186,198,1)), color-stop(80%,rgba(221,223,227,1)), color-stop(100%,rgba(245,246,246,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f6f6', endColorstr='#f5f6f6',GradientType=0 ); /* IE6-9 */
Hopefully that helps.
Three things:
Get your gradient CSS from this site: http://www.colorzilla.com/gradient-editor/
Update your border-radius to specify the units: border-radius: 3px 3px;
Add # to your border-color declaration: border: 1px solid #BFBFBF;

Make background with css3

How can i make this background with css3? Image
I want to repeat it and want not use a image.
thanks for help
You can do this using CSS3 gradients:
background: -moz-linear-gradient(top, #ffffff 0%, #ffffff 49%, #eaa82c 50%, #eaa82c 80%, #bc2020 81%, #bc2020 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(49%,#ffffff), color-stop(50%,#eaa82c), color-stop(80%,#eaa82c), color-stop(81%,#bc2020), color-stop(100%,#bc2020)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* IE10+ */
background: linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#bc2020',GradientType=0 ); /* IE6-9 */
}
http://jsfiddle.net/gDJtD/
I suggest you have a look at http://lea.verou.me/css3patterns/ for this
Having said that, images are always going to be faster. Beware of not using css gradients just for the sake of using css gradients.