Reputation: 79
I currently have a little problem, but I think it is not possible to do it with only css3, I want to get a image name from the title attribute and use it on the background-image url, like this:
#wizHeader li a[title^="step_"]{
background-image: url("../images/" + attr(title) + ".png");
}
is this possible with only css3?
Upvotes: 0
Views: 100
Reputation: 4397
If you use jQuery:
$(document).ready(function() {
$('#wizHeader li a[title^="step_"]').each(function(k, v) {
var title = $(v).attr('title');
$(v).attr('style', 'background-image: url("../images/' + title + '.png")');
});
});
Upvotes: 0
Reputation: 34566
Presently not possible. The attr
function in CSS has great potential but, to my knowledge, at least cross-browser, it is presently usable only as part of the content
property of pseudo elements, e.g.
.foo:after { content: attr(title); }
Further info at this question.
And here on CSS Tricks.
Upvotes: 2