Proprietatea CSS content
se foloseste pentru a genera continut intr-un element HTML direct din CSS. Poate fi utilizata cu pseudo-elementele :after
si :before
.
<style> .cnt_ex1:before { content: '~> '; color: #0000d0; } .cnt_ex1:after { content: ' <~'; color: #0000d0; } </style> <div class='cnt_ex1'>CoursesWeb.net</div> <div class='cnt_ex1'>MarPlo.net</div>
Elementul <style> din aceste exemple se adauga in sectiunea <head> din pagina.
none
- Pseudo-elementul nu e creat.normal
- Evalueza ca none
(default).counter(counter_index)
- Seteaza valoarea ca un contor.counter-increment
.
<style> .cnt_ex2 { counter-increment: ex_index; /* Sets a counter to be increased */ } .cnt_ex2:before { /* Space is added to create a space between counter and rest of content */ content: counter(ex_index) '. '; color: #0000d0; } </style> <div class='cnt_ex2'>CoursesWeb.net</div> <div class='cnt_ex2'>MarPlo.net</div>
attr(attribute)
- Un sir cu valoarea din atributul specificat.string
- Un text adaugat pt. continut. Se pot adauga si caractere speciale, folosind codul Hex, cu back-slash "\" la inceput ( content: '\Hex-code'; ).
content: '\27A4'; /* Displays: ➤ */
open-quote
| close-quote
- Valoarea este ghilimele de inceput | sfarsit.no-open-quote
| no-close-quote
- Elimina ghilimele de inceput | sfarsit, daca au fost adaugate.url('url')
- Adauga continutul de la adresa "url" specificata (imagine, sunet, video, etc.).<style> .cnt_ex3:before { content: url('https://coursesweb.net/imgs/8.gif'); margin-right: 10px; } </style> <div class='cnt_ex3'>CoursesWeb.net</div> <div class='cnt_ex3'>MarPlo.net</div>
<style> ul.li_mark1 { list-style: none; } ul.li_mark1 li:before { content: '\00BB'; /* Escaped Hex code notation */ padding-right: 8px; } </style> <ul class='li_mark1'> <li>Free Courses and Tutorials</li> <li>HTML-CSS examples</li> <li>Today is a good day for "Doing" Nothing</li> </ul>
\a
unde vreti crearea unui nou rand, si proprietatea white-space: pre;
<style> #cnt_ex4:after { color:#0000e0; content: '- Text from content \a Another line.'; white-space: pre; } </style> <div id='cnt_ex4'>HTML Div.</div>
<form action="script.php" method="post"> ... </form>
#id { background-color: #bbfeda; box-shadow: 11px 11px 5px #7878da; }
var fruits = ["mar", "cireasa", "banana"]; fruits.shift(); alert(fruits.length); // 2
if(extension_loaded("PDO") === true) echo "PDO este valabil."
Can I listen to music? - Pot asculta muzica?
Me gustan las frutas dulces. - Imi plac fructele dulci.