freeCodeCamp/curriculum/challenges/italian/01-responsive-web-design/basic-html-and-html5/turn-an-image-into-a-link.md

2.6 KiB

id title challengeType videoUrl forumTopicId dashedName
bad87fee1348bd9aedf08820 Trasformare un'immagine in un collegamento 0 https://scrimba.com/p/pVMPUv/cRdBnUr 18327 turn-an-image-into-a-link

--description--

È possibile trasformare in link degli elementi annidandoli all'interno di un elemento a.

Metti la tua immagine all'interno di un elemento a. Ecco un esempio:

<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="Three kittens running towards the camera."></a>

Ricordati di usare # come proprietà href dei tuoi elementi a per trasformarli in link vuoti.

--instructions--

Posiziona l'elemento immagine esistente all'interno di un elemento a (anchor).

Una volta fatto questo, passa sopra alla tua immagine con il cursore. Il puntatore normale del cursore dovrebbe diventare il puntatore di clic del collegamento. La foto è ora un collegamento.

--hints--

L'elemento img esistente deve essere annidato all'interno di un elemento a.

assert($('a').children('img').length > 0);

Il tuo elemento a dovrebbe essere un link vuoto con un attributo href impostato su #.

assert(new RegExp('#').test($('a').children('img').parent().attr('href')));

Ognuno dei tuoi elementi a dovrebbe avere un tag di chiusura.

assert(
  code.match(/<\/a>/g) &&
    code.match(/<a/g) &&
    code.match(/<\/a>/g).length === code.match(/<a/g).length
);

--seed--

--seed-contents--

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back.">

  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>

--solutions--

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>