Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to put this image https://s32.postimg.org/3ks1zaggl/lightbulb.png[^] in the Gradient strip - left side.

I tried a lot but not succeed. Here is my code...

CSS

CSS
.class
{
background-image: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png');
background-repeat: no-repeat;
background-size: 35px 35px;
vertical-align:middle;
margin:20px 0 20px 0;
padding-left: 45px;
display: block;  
height:35px;
padding-top:5px;
color: white;
font-weight: bold;
font-size:18px;

/*-----------------------------
   Gradient Code
--------------------------------*/

background: -moz-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* ff3.6+ */
    background: -webkit-gradient(linear, left bottom, right top, color-stop(0%, rgba(0,0,0,1)), color-stop(100%, rgba(0,128,128,0))); /* safari4+,chrome */
    background: -webkit-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* safari5.1+,chrome10+ */
    background: -o-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* opera 11.10+ */
    background: -ms-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* ie10+ */
    background: linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* w3c */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#008080', endColorstr='#000000',GradientType=1 ); /* ie6-9 */
}



HTML
<p class="class">hello</p>


What I have tried:

Here is JSFiddle:

Edit fiddle - JSFiddle[^]
Posted
Updated 11-Jul-16 4:43am
v3

1 solution

Hi,

It is simple. You can combine a background-image and CSS3 gradient on the same element. Please try the below code.

CSS
.class
{
background-repeat: no-repeat;
background-size: 35px 35px;
vertical-align:middle;
margin:20px 0 20px 0;
padding-left: 45px;
display: block;  
height:35px;
padding-top:5px;
color: white;
font-weight: bold;
font-size:18px;
z-index: 100;

/*-----------------------------
   Gradient Code
--------------------------------*/

background: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png'), -moz-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* ff3.6+ */
    background: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png'), -webkit-gradient(linear, left bottom, right top, color-stop(0%, rgba(0,0,0,1)), color-stop(100%, rgba(0,128,128,0))); /* safari4+,chrome */
    background: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png'), -webkit-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* safari5.1+,chrome10+ */
    background: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png'), -o-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* opera 11.10+ */
    background: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png'), -ms-linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* ie10+ */
    background: url('https://s32.postimg.org/3ks1zaggl/lightbulb.png') no-repeat, linear-gradient(45deg, rgba(0,0,0,1) 0%, rgba(0,128,128,0) 100%); /* w3c */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#008080', endColorstr='#000000',GradientType=1 ); /* ie6-9 */
}



Hope this will help you :).
 
Share this answer
 
v2
Comments
Pr!y@ 11-Jul-16 12:41pm    
will you please please remove the site link use this link
https://s32.postimg.org/3ks1zaggl/lightbulb.png
Prava-MFS 11-Jul-16 14:46pm    
Done :) (y).
Pr!y@ 14-Jul-16 12:27pm    
Sir this is not working on chrome, why ? any idea?
Pr!y@ 14-Jul-16 12:40pm    
Ohh Solved no-repeat was missing :) Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900