string concatenation in css

后端 未结 4 1077
轻奢々
轻奢々 2020-12-03 13:32

I want to achieve the following in css. How do i do it in a way that works in IE8+

url(\'../img/icons/\' + attr(\'type\') + \'_10.png\')
4条回答
  •  生来不讨喜
    2020-12-03 14:22

    CSS performs concatenation without using any operator (e.g. +, &, etc). Keep your strings in quotes combine the strings, attr, var, etc into one line.

    Examples:

    • url('not/very' '/useful/concatenation'); // not/very/useful/concatentation
    • url('../img/icons/' attr('type') '_10.png'); //../img/icons/${type}_10.png
    • url(attr('href') '#hash'); // https://${href}/#hash
    • url(var(--hello) ' world'); // Hello World

提交回复
热议问题