How to add text or characters using CSS (without javascript)?

Well, it should work in IE, I know that IE does not support the content property of something else?

+3
source share
5 answers

The only option is the property content:

The content property is used with :beforeand :afterpseudo-elements to insert the generated content.

But, as you point out, this is part of CSS 3 and is not supported by IE. In the meantime, you will need to compensate for the use of JavaScript.

+13
source

Javascript, HTML CSS. , , CSS HTML, , IE ( ), CSS display , . MSDN, IE 8+ CSS :after content:, IE 7 .

:

<style type="test/css" media="screen">
.printonly { display: inline; }
</style>

<style type="text/css" media="print">
#maintitle:after { content:" \2014  Site Title";} /* for IE8+ and Other Browsers. sidenote: Can't use &mdash directly in generated content, so using escape code */
.printonly { display:inline } /* For IE <= 7 */
</style>

<h1 id="maintitle">Page Title 
    <!--[if lte IE 7]><span class="printonly">&mdash; Site Title</span><![endif]-->
</h1>
+2

- .

+1

IE8.js , . , ,

+1

- JavaScript CSS3.

, , , - .

Why can't you do this with js?

0
source

Source: https://habr.com/ru/post/1717872/


All Articles