Advertisement
fcamuso

Corso recupero Javascript - video 8

Nov 15th, 2022
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.90 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="it">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <style>
  8.         .cuore {
  9.             position:relative;
  10.             width:50px;
  11.             height:40px;
  12.             -moz-transform:rotate(0);
  13.             -webkit-transform:rotate(0);
  14.             -ms-transform:rotate(0);
  15.             -o-transform:rotate(0);
  16.             transform:rotate(0);
  17.             display: none;
  18.         }
  19.         .cuore:before {
  20.             content:"";
  21.             width:20px;
  22.             height:30px;
  23.             position:absolute;
  24.             top:0;
  25.             left:18px;
  26.             background:red;
  27.             border-radius:60px 60px 0 0;
  28.             -moz-transform:rotate(-45deg);
  29.             -webkit-transform:rotate(-45deg);
  30.             -ms-transform:rotate(-45deg);
  31.             -o-transform:rotate(-45deg);
  32.             transform:rotate(-45deg);
  33.             -moz-transform-origin:0 100%;
  34.             -webkit-transform-origin:0 100%;
  35.             -ms-transform-origin:0 100%;
  36.             -o-transform-origin:0 100%;
  37.             transform-origin:0 100%;
  38.         }
  39.         .cuore:after {
  40.             content:"";
  41.             width:20px;
  42.             height:30px;
  43.             position:absolute;
  44.    
  45.             left:0;
  46.             top:0;
  47.             background:red;
  48.             border-radius:60px 60px 0 0;
  49.             -moz-transform:rotate(45deg);
  50.             -webkit-transform:rotate(45deg);
  51.             -ms-transform:rotate(45deg);
  52.             -o-transform:rotate(45deg);
  53.             transform:rotate(45deg);
  54.             -moz-transform-origin:100% 100%;
  55.             -webkit-transform-origin:100% 100%;
  56.             -ms-transform-origin:100% 100%;
  57.             -o-transform-origin:100% 100%;
  58.             transform-origin:100% 100%;
  59.         }
  60.         .iscrizione{
  61.             background-color: lightgray;
  62.             padding: 10px;
  63.             font-weight: bold;
  64.             color: black;
  65.             border-radius: 5px;
  66.             display: inline-block;
  67.             cursor: pointer;
  68.         }
  69.     </style>
  70.     <title>YouTube</title>
  71. </head>
  72. <body>
  73.     <img src="img/londra1.jpg" alt=""><br>
  74.     <div class="iscrizione">
  75.         ISCRIVITI
  76.     </div><br><br>
  77.    
  78.   <div class="cuore">
  79.         &nbsp;
  80.   </div>
  81.    
  82.   <script>
  83.         function cambiaAspetto(ele, dati)
  84.         {
  85.             ele.style.color = dati.testo;
  86.             ele.style.backgroundColor = dati.sfondo;
  87.             ele.textContent = dati.scritta;
  88.         }
  89.  
  90.     const div = document.querySelector(".iscrizione");    //getElementsByClassName("classe")
  91.        
  92.         const datiOriginali = {testo: "black",sfondo: "lightgray", scritta: "ISCRIVITI"};
  93.         const datiCambiati = {testo: "white",sfondo: "red", scritta: "ISCRITTO"};
  94.  
  95.     div.addEventListener("click", function () {
  96.             if (getComputedStyle(this).color === "rgb(0, 0, 0)")
  97.            cambiaAspetto(this, datiCambiati);
  98.             else
  99.               cambiaAspetto(this, datiOriginali);
  100.                
  101.            
  102.               // if (getComputedStyle(this).color === "rgb(0, 0, 0)")
  103.               // {
  104.  
  105.                 //  this.style.backgroundColor = "red";
  106.         //  this.style.color = "white";
  107.         //  this.textContent = "ISCRITTO";
  108.                 // }
  109.                 // else
  110.                 // {
  111.                 //  this.style.backgroundColor = "lightgray";
  112.         //  this.style.color = "black";
  113.         //  this.textContent = "ISCRIVITI";                
  114.                 // }
  115.     });
  116.  
  117.   </script>
  118. </body>
  119. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement