0

How can I make it so that the background of a button HTML tag has a background image and also has a transparent background using CSS/html?

I have the following HTML

<button style="backgroud-image: url('../images/example.png');"></button>

1 Answer 1

1

You will want to use the opacity property.

The value of this property can be 0-1 with zero being transparent and 1 being fully opaque.

As noted by @Tah Tatsumoto, this will change the entire opacity of the button, including text.

button{
  background-image: url('http://www.joomlaworks.net/images/demos/galleries/abstract/7.jpg'); 
  background-size:contain;
  height:100px;
  width:100px;
  opacity:0.5;
}
<button>Hello</button>

2
  • Note that this will change the opacity of the entire button, including the text
    – Tah
    Commented Apr 4, 2016 at 23:38
  • True! Changed answer.
    – Wowsk
    Commented Apr 4, 2016 at 23:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.