2.2 KiB
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
bad87fee1348bd9aedf08746 | Ereditare gli stili dall'elemento Body | 0 | https://scrimba.com/c/c9bmdtR | 18204 | inherit-styles-from-the-body-element |
--description--
Abbiamo visto che ogni pagina HTML ha un elemento body
, e che anche il suo elemento body
può essere stilizzato con CSS.
Ricorda, puoi stilizzare il tuo elemento body
proprio come qualsiasi altro elemento HTML, e tutti gli altri elementi erediteranno gli stili dell'elemento body
.
--instructions--
Per prima cosa, crea un elemento h1
con il testo Hello World
Quindi, dai a tutti gli elementi sulla tua pagina il colore green
aggiungendo color: green;
alla tua dichiarazione di stile dell'elemento body
.
Infine, dai al tuo elemento body
la font-family di monospace
aggiungendo font-family: monospace;
alla tua dichiarazione di stile per l'elemento body
.
--hints--
Dovresti creare un elemento h1
.
assert($('h1').length > 0);
Il tuo elemento h1
dovrebbe contenere il testo Hello World
.
assert(
$('h1').length > 0 &&
$('h1')
.text()
.match(/hello world/i)
);
Il tuo elemento h1
dovrebbe avere un tag di chiusura.
assert(
code.match(/<\/h1>/g) &&
code.match(/<h1/g) &&
code.match(/<\/h1>/g).length === code.match(/<h1/g).length
);
Il tuo elemento body
dovrebbe avere la proprietà color
di green
.
assert($('body').css('color') === 'rgb(0, 128, 0)');
Il tuo elemento body
dovrebbe avere la proprietà font-family
di monospace
.
assert(
$('body')
.css('font-family')
.match(/monospace/i)
);
Il tuo elemento h1
dovrebbe ereditare il font monospace
dal tuo elemento body
.
assert(
$('h1').length > 0 &&
$('h1')
.css('font-family')
.match(/monospace/i)
);
Il tuo elemento h1
dovrebbe ereditare il colore green
dal tuo elemento body
.
assert($('h1').length > 0 && $('h1').css('color') === 'rgb(0, 128, 0)');
--seed--
--seed-contents--
<style>
body {
background-color: black;
}
</style>
--solutions--
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
</style>
<h1>Hello World!</h1>