Kevin  Suzuki
Kevin Suzuki

Reputation: 25

How can I make no-repeat for background?

I want to make no-repeat picture (background) for javascript.

e.target.style.backgroundImage = "url(sozai/a.jpg)";

In this case a.jpg will be shown as a background repeatedly but I want to have no-repeat.

Also I want to make change of transparency of the picture.

Upvotes: 1

Views: 123

Answers (2)

Pavan Teja
Pavan Teja

Reputation: 3202

for no-repeat

e.target.style.backgroundRepeat = "no-repeat";

for transparency

e.target.style.opacity = "0.7"; 

Upvotes: 1

Arun P Johny
Arun P Johny

Reputation: 388356

You can set background-repeat property like

e.target.style.backgroundImage = "url(sozai/a.jpg)";
e.target.style.backgroundRepeat = "no-repeat";

or simplified

e.target.style.background = "url(sozai/a.jpg) no-repeat";

Upvotes: 5

Related Questions