Is it possible to use a variable within the background-image of a style template?
I am trying to achieve something like the following:
<script>
export default {
name: 'setCss',
computed: {
cssVars() {
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
var path = '';
if(isAndroid) {
path = 'img/samsung/';
} else{
path = 'img/iphone/';
}
return {
'--bg-path': path,
}
}
}
};
</script>
and then with this CSS:
<style scoped>
div {
background-image: var(--bg-path) + '/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="37060401014f03070777054f4c147054">[email protected]</a>';
background-size: 1366px 400px;
}
@media not all,
not all,
only screen and (max-width: 480px) {
div {
background-image: var(--bg-path) + '/480x288.jpg';
background-size: 480px 288px;
}
}
</style>
This approach does not seem to work, but I am exploring alternative ways to achieve this. Any suggestions?