freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-css-grid-by-building-.../614387cbefeeba5f3654a291.md

153 lines
4.0 KiB
Markdown

---
id: 614387cbefeeba5f3654a291
title: Step 7
challengeType: 0
dashedName: step-7
---
# --description--
Dopo l'elemento `header`, crea un elemento `div` con l'attributo `class` impostato su `author`.
All'interno di questo `div`, crea un elemento `p` con un attributo `class` di `author-name` e dagli il testo `By freeCodeCamp`. Racchiudi `freeCodeCamp` in un elemento `a` con l'attributo `href` impostato su `https://freecodecamp.org` e l'attributo `target` impostato su `_blank`.
Sotto questo, aggiungi un secondo elemento `p` con la classe `publish-date` e il testo `March 7, 2019`.
# --hints--
Dovresti creare un elemento `div`.
```js
assert.exists(document.querySelector('div'));
```
L'elemento `div` dovrebbe trovarsi dopo l'elemento `header`.
```js
assert(document.querySelector('div')?.previousElementSibling?.localName === 'header');
```
L'elemento `div` dovrebbe avere l'attributo `class` impostato su `author`.
```js
assert(document.querySelector('div')?.className === 'author');
```
Dovresti creare due nuovi elementi `p`.
```js
assert(document.querySelectorAll('p')?.length === 3);
```
I nuovi elementi `p` dovrebbero trovarsi all'interno dell'elemento `div`.
```js
assert.exists(document.querySelector('div')?.querySelectorAll('p')?.length === 2);
```
Il primo nuovo elemento `p` dovrebbe avere un attributo `class` con il valore `author-name`.
```js
assert(document.querySelector('div')?.querySelector('p')?.className === 'author-name');
```
Il primo nuovo elemento `p` dovrebbe avere il testo `By freeCodeCamp`.
```js
assert(document.querySelector('div')?.querySelector('p')?.innerText === 'By freeCodeCamp');
```
Il secondo nuovo elemento `p` dovrebbe avere un attributo `class` con il valore `publish-date`.
```js
assert(document.querySelector('div')?.querySelectorAll('p')?.[1]?.className === 'publish-date');
```
Il secondo nuovo elemento `p` dovrebbe avere il testo `March 7, 2019`.
```js
assert(document.querySelector('div')?.querySelectorAll('p')?.[1]?.innerText === 'March 7, 2019');
```
Dovresti creare un elemento `a`.
```js
assert.exists(document.querySelector('a'));
```
L'elemento `a` dovrebbe essere annidato nel primo nuovo elemento `p`.
```js
assert(document.querySelector('div')?.querySelector('p')?.firstElementChild?.localName === 'a');
```
L'elemento `a` dovrebbe avere un attributo `href` con il valore `https://freecodecamp.org`.
```js
assert(document.querySelector('div')?.querySelector('p')?.firstElementChild?.getAttribute('href') === 'https://freecodecamp.org');
```
L'elemento `a` dovrebbe avere un attributo `target` con il valore `_blank`.
```js
assert(document.querySelector('div')?.querySelector('p')?.firstElementChild?.getAttribute('target') === '_blank');
```
L'elemento `a` dovrebbe racchiudere il testo `freeCodeCamp`.
```js
assert(document.querySelector('div')?.querySelector('p')?.firstElementChild?.textContent === 'freeCodeCamp');
```
# --seed--
## --seed-contents--
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Magazine</title>
<link
href="https://fonts.googleapis.com/css?family=Anton%7CBaskervville%7CRaleway&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
/>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<main>
<section class="heading">
<header class="hero">
<img
src="https://cdn.freecodecamp.org/platform/universal/fcc_meta_1920X1080-indigo.png"
alt="freecodecamp logo"
loading="lazy"
class="hero-img"
width="400"
/>
<h1 class="hero-title">OUR NEW CURRICULUM</h1>
<p class="hero-subtitle">
Our efforts to restructure our curriculum with a more project-based
focus
</p>
</header>
--fcc-editable-region--
</section>
</main>
--fcc-editable-region--
</body>
</html>
```
```css
```