I'm having trouble in changing the image color inside of a button.
Here's the image.
I want the black download button icon change to green icon if possible in CSS? or any other way to make it like that? Instead of re-creating it again
And for the code:
<button><em class="leftImage"></em>Button<em class='rightImage'></em></button>
button{
margin: 0px;
padding: 0px;
font-family:Lucida Sans MS, Tahoma;
font-size: 12px;
color: #000;
white-space:nowrap;
width:auto;
overflow:visible;
height:28px;
}
button em{
vertical-align:middle;
margin:0 2px;
display:inline-block;
width:16px;
height:16px;
background-image: url(icon_delete.png);
}
button em.leftImage{
background-position: -96px -112px;
}
button em.rightImage{
background-position: -64px -16px;
}
But the output is not changing the color. its still black.
https://jsfiddle.net/35kfu6z7/
You original code doesn't make much sense.
What you have here is an image with the 2 versions of your button. You can use a technique called CSS Sprites: https://css-tricks.com/css-sprites/
The idea here is to force the size of the button element to be the same size as the button on your image, then offset it using the background-position property to align it properly inside your button.
Here is an example using the picture you provided and 2 different clases (with 2 different offset) to show either the green or the black:
button{
display:inline-block;
width:84px;
height:26px;
background-image: url(http://i.stack.imgur.com/8aNAf.png);
background-color: none;
border: none;
}
button.green{
background-position: -3px 31px;
}
button.black{
background-position: -3px -3px;
}
<button class="green"></button>
<button class="black"></button>
Best would be to use a font like fontawesome for the icon. That way you can easily change the colour. Or use filters, see: Change color of PNG image via CSS?.
Can you link the actual image file you are using into your jsfiddle?
Try https://jsfiddle.net/35kfu6z7/1/
button em{
vertical-align:middle;
display:inline-block;
width:29px;
height:30px;
background-image: url(http://imgur.com/download/vICywDr/);
repeat:none;
}
button em.leftImage{
background-position: -28px, 0;
}
button em.rightImage{
background-position: 0, 0;
}
Same idea that #Jean-Yves Fargeat suggested(not enough rep to comment)
try this
html
<button onclick="green()";>
<div id="border">
<div id="square">
<div id="arrow"></div>
</div>
</div><span>download</span>
</button>
css
#border {
border: 2px solid black;
border-radius: 50%;
display: inline-block;
padding: 2px 6px 6px 6px;
position: relative;
top: 5px;
}
#square {
background: #000;
width: 4px;
height: 8px;
position: relative;
}
#arrow {
display: inline-block;
border: 5px solid;
border-color: black transparent transparent transparent;
position: absolute;
top: 100%;
left: -70%;
}
button span{
line-height: 30px;
margin: 5px;
}
javascript
function green() {
document.getElementById('border').style.borderColor = "green";
document.getElementById('square').style.background = "green";
document.getElementById('arrow').style.borderColor = "green transparent transparent transparent";
}
see here jsfiddle.net/hworm4/mpj47fLb/
Why not change the color of the image using photoshop?
Related
I am using dreamweaver to create a website and I thought of just using Photoshop to create backgrounds. I decided to do so only because in case I'd choose to change the button name easily by just editing the codes, I could just refer to the code. If I would construct buttons using Photoshop, I wouldn't be able to edit the Texts in those buttons or in any element easily.
So my question is simple, How do I create a button that has a simple inline style making it transparent leaving the value of the button still visible.
.button {
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
}
It still leaves a border shade after your click it.
To get rid of the outline when clicking, add outline:none
JSFiddle example
button {
background-color: transparent;
background-repeat: no-repeat;
border: none;
cursor: pointer;
overflow: hidden;
outline: none;
}
button {
background-color: transparent;
background-repeat: no-repeat;
border: none;
cursor: pointer;
overflow: hidden;
outline: none;
}
<button>button</button>
The solution is pretty easy actually:
<button style="border:1px solid black; background-color: transparent;">Test</button>
This is doing an inline style. You're defining the border to be 1px, solid line, and black in color. The background color is then set to transparent.
UPDATE
Seems like your ACTUAL question is how do you prevent the border after clicking on it. That can be resolved with a CSS pseudo selector: :active.
button {
border: none;
background-color: transparent;
outline: none;
}
button:focus {
border: none;
}
JSFiddle Demo
Make a div and use your image ( png with transparent background ) as the background of the div, then you can apply any text within that div to hover over the button. Something like this:
<div class="button" onclick="yourbuttonclickfunction();" >
Your Button Label Here
</div>
CSS:
.button {
height:20px;
width:40px;
background: url("yourimage.png");
}
<div class="button_style">
This is your button value
</div>
.button_style{
background-color: Transparent;
border: none; /* Your can add different style/properties of button Here*/
cursor:pointer;
}
Setting its background image to none also works:
button {
background-image: none;
}
**add the icon top button like this **
#copy_btn{
align-items: center;
position: absolute;
width: 30px;
height: 30px;
background-color: Transparent;
background-repeat:no-repeat;
border: none;
cursor:pointer;
overflow: hidden;
outline:none;
}
.icon_copy{
position: absolute;
padding: 0px;
top:0;
left: 0;
width: 25px;
height: 35px;
}
<button id="copy_btn">
<img class="icon_copy" src="./assest/copy.svg" alt="Copy Text">
</button>
I couldn't find an already existing question that answers the following problem:
I have added a 300 x 300 Pixel squared png-image of a circle to my website. I am using Zurb's Foundation 5.0.2 as a CSS Grid-basis.
I would like to create a CSS-border around the circle and add an opacity-effect so that
the image is only fully visible when you hover over it with your mouse. The surrounding CSS-border and background should not be affected by this hovering-effect. Please have a look at the links to see the images.
This is my code so far:
HTML:
<div class="large-4 columns" id="border">
<div id="foto"><img src="/img/test.png" alt="Portrait" width="300" height="300"></div>
</div>
CSS:
#border #foto {
border-radius: 50%;
width: 300px;
height:300px;
background: #1ABC9C;
border: 15px solid #34495E;
}
#foto:hover {
opacity: 1.0;
}
#foto {
opacity:0.5;
}
This code correctly displays the border around the circle, but applies the hovering-effect to both, border and image:
https://www.dropbox.com/s/2r989g7d14exyfr/screenshot1.png
When I modify the CSS in the following way, it correctly applies the hover-effect only to the picture, but reduces the image size and doesn't display it centered any longer:
#border {
border-radius: 50%;
width: 300px;
height:300px;
background: #1ABC9C;
border: 15px solid #34495E;
}
https://www.dropbox.com/s/izmohri8bxkngp6/screenshot2.png?m=
Could you please advise me how to display the image correctly and apply the hover-effect as intended?
Thank you very much.
Add overflow:hidden to your border & foto div(s).
#border #foto {
border-radius: 50%;
width: 300px;
height:300px;
background: #1ABC9C;
border: 15px solid #34495E;
overflow: hidden;
}
http://jsfiddle.net/ufdM7/
Remove border from #border #foto and add overflow:hidden to it.
Write:
#foto:hover {
opacity: 1.0;
}
#foto {
opacity:0.5;
}
#border {
border-radius: 50%;
width: 300px;
height:300px;
background: #1ABC9C;
border: 15px solid #34495E;
overflow:hidden;
}
Fiddle here.
I did this way:
http://jsfiddle.net/u9LrK/1/
#foto, #foto img {
background: #1ABC9C;
border-radius:50%;
}
#foto {
border-radius: 50%;
border: 15px solid #34495E;
height: 300px;
width: 300px;
}
#foto:hover img {
cursor: pointer;
opacity: 0.5;
}
This is what you want?
I have an box which is an image and I have text inside the image which will be geenrated dynamically.
Please look at the attached screenshot for more information.
How do I make sure that the image stretches when there is more text ?
.my-community-box{
background: url('/assets/my-community-box.png') no-repeat !important;
background-size: 100%;
width: 287px;
min-height: 474px;
float: right;
.my-community-details{
background-color: #mild-gray;
margin: 20px 10px 10px 10px;
padding: 5px;
ul{
width: 250px;
margin: 0 0 9px 0;
li{
}
}
a{
color: #darker-green;
}
a:hover{
text-decoration: none;
color: #light-green;
}
}
Why not use a border?
.my-community-box{
background: #F3F3F2;
width: 287px;
min-height: 474px;
float: right;
border: 3px solid #C5C3C3;
}
.my-community-box-wrap{
border-left: 2px solid #C2E2A0;
border-right: 2px solid #C2E2A0;
float: right;
}
Demo: http://jsfiddle.net/AWXHr/
you will need to background-repeat: repeat-y; the image, but will have to change it. as far as it seems, it is one single image - you will have to crop it to have the top border and the "body" of the image will be the part that you want to vertical repeat.
alternatively, due to the simple design, you could just use css borders
EDIT
also, as a few comments suggested, you should show us some code and not just an image, that would help a lot!
Use css border instead of image
div{
border:#333 solid 6px; border-radius:0 0 6px 6px;
box-shadow: 0px 0px 0px 2pt green;
height:auto;
width:200px;
background:#c1c1c1
}
Demo http://jsfiddle.net/wYUFD/12/
Demo
Hi now used to background-size:cover; or max-width
as like this
p{
max-width:200px;
border:solid 10px red;
background:url('http://www.gravatar.com/avatar/eb71f65106648cf6618b10423e8b0451?s=32&d=identicon&r=PG') no-repeat;
background-size:cover;
color:#fff;
}
Demo
I hope this may be helpful to you
.my-community-details{
background-color: #mild-gray;
margin: 20px 10px 10px 10px;
padding: 5px;
max-width: //set what depends up on your image width
max-height: //set what depends up on your image height
overflow-y: auto;
In my CSS I tried to mask a button's look by adding a background like this:
input[type=button]
{
background-image:url('../images/next-button.png');
background-position:0px;
background-repeat: no-repeat;
height:60px;
width:120px;
outline: 0;
}
input[type=button]:hover
{
background-position: 0px -66px;
}
input[type=button]:active
{
background-position: 0px -132px;
}
the new background shows up, but there is still a gray border around the background from the button itself. how do i remove this? The background image is a transarent PNG so I know this outline isn't from the image I'm using.
here is the HTML for the button
<input type="button" id="submit1" />
Thanks a bunch!
!--EDIT--
This is the proper way to do it! thanks for the answers guys!
CSS:
input[type=button]
{
border: none ;
background-image:url('../images/next-button.png');
background-position:0px;
background-repeat: no-repeat;
height:60px;
width:120px;
outline: 0;
}
input[type=button]:hover
{
background-position: 0px -66px;
}
input[type=button]:active
{
background-position: 0px -132px;
}
.next_btn{
border: none ;
color:#FFFFFF;
background-color:#FFFFFF;
}
and the HTML:
<input type="button" class="next_btn" id="submit1"/>
Try adding in
border: none
as an attribute for input[type=button].
I've got a simple CSS/HTMl question. I've got an image and some text in a div. I've got the text positioned on top of the image using the z-index.
The text is white with a black background. I adjusted the text's div's opacity, so that the image beneath it is visible. It looks good.
The problem is that the text appears gray instead of white, because the opacity is lowered. How can I make the text appear white, and still have a semi-transparent black background around it?
<style type="text/css">
.wrap {
position:relative;
float:left;
clear:none;
overflow:hidden;
}
.wrap img {
position:relative;
z-index:1;
}
.wrap .desc {
display:block;
position:absolute;
width:166px;
top:20px;
left:20px;
z-index:2;
color: #FFFFFF;
padding: 10px;
background-color: #000000;
border-radius: 5px 5px 5px 5px;
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
/*For IE*/
filter: alpha(opacity=60);
opacity: 0.60;
}
</style>
<div class="wrap">
<img src="path/to/pic.png" />
<h6 class="desc">This is my text about my image</h3>
</div>
Any suggestions?
How about like this:
CSS
.mod {
position: relative;
width: 80px;
height: 100px;
padding: 5px;
}
.mod-text,
.mod-background {
position: absolute;
left: 0;
width: 100%;
}
.mod-text {
color: #FFF;
font-size: 1em;
text-align: center;
bottom: 0;
}
.mod-background {
background-color: #f58322;
border-radius: 8px;
filter: alpha(opacity=60);
opacity: 0.60;
top: 0;
height: 100%;
}
HTML
<div class="mod">
<img src="http://www.gravatar.com/avatar/d543f6789b58df56f6fed95291e78261.png" />
<div class="mod-background">
</div>
<div class="mod-text">
Hawt!
</div>
</div>
Plnkr
http://plnkr.co/edit/aSd9rO?p=preview
Depending on your browser support requirements, you might be able to get away with leaving opacity at 100%, and using an rgba color:
background-color: rgba(0,0,0,0.5);
The colors are Red, Green, Blue, (0-255 each) followed by Alpha (0-1.0).
If you need a fallback in older browsers, you can usually use:
background-color: #000;
background-color: rgba(0,0,0,0.5);
This will default to Black for older browsers, and semi-transparent for newer ones. It avoids an extra download (of a tiling image), as well as keeping more of your styling in the text file (easier to version, maintain, and find).
I would create another div before the description with the same height and width, set that div's opacity to transparent, add a background, then put the description in another div, without a background. If they both have absolute position, then the latter should go on top of the former.
See the demo here.
You can put a semi-transparent image in the background of the element instead. The actual image can be very small and you can repeat it to cover the whole background.
.wrap .desc {
display: block;
position: absolute;
width: 166px;
top: 20px;
left: 20px;
z-index: 2;
color: #FFFFFF;
padding: 10px;
background: url('my-small-bg.png');
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
Here's an example of what this could look like: http://jsfiddle.net/f6XS6/1/