Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="it">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- .cuore {
- position:relative;
- width:50px;
- height:40px;
- -moz-transform:rotate(0);
- -webkit-transform:rotate(0);
- -ms-transform:rotate(0);
- -o-transform:rotate(0);
- transform:rotate(0);
- display: none;
- }
- .cuore:before {
- content:"";
- width:20px;
- height:30px;
- position:absolute;
- top:0;
- left:18px;
- background:red;
- border-radius:60px 60px 0 0;
- -moz-transform:rotate(-45deg);
- -webkit-transform:rotate(-45deg);
- -ms-transform:rotate(-45deg);
- -o-transform:rotate(-45deg);
- transform:rotate(-45deg);
- -moz-transform-origin:0 100%;
- -webkit-transform-origin:0 100%;
- -ms-transform-origin:0 100%;
- -o-transform-origin:0 100%;
- transform-origin:0 100%;
- }
- .cuore:after {
- content:"";
- width:20px;
- height:30px;
- position:absolute;
- left:0;
- top:0;
- background:red;
- border-radius:60px 60px 0 0;
- -moz-transform:rotate(45deg);
- -webkit-transform:rotate(45deg);
- -ms-transform:rotate(45deg);
- -o-transform:rotate(45deg);
- transform:rotate(45deg);
- -moz-transform-origin:100% 100%;
- -webkit-transform-origin:100% 100%;
- -ms-transform-origin:100% 100%;
- -o-transform-origin:100% 100%;
- transform-origin:100% 100%;
- }
- .iscrizione{
- background-color: lightgray;
- padding: 10px;
- font-weight: bold;
- color: black;
- border-radius: 5px;
- display: inline-block;
- cursor: pointer;
- }
- </style>
- <title>YouTube</title>
- </head>
- <body>
- <img src="img/londra1.jpg" alt=""><br>
- <div class="iscrizione">
- ISCRIVITI
- </div><br><br>
- <div class="cuore">
-
- </div>
- <script>
- function cambiaAspetto(ele, dati)
- {
- ele.style.color = dati.testo;
- ele.style.backgroundColor = dati.sfondo;
- ele.textContent = dati.scritta;
- }
- const div = document.querySelector(".iscrizione"); //getElementsByClassName("classe")
- const datiOriginali = {testo: "black",sfondo: "lightgray", scritta: "ISCRIVITI"};
- const datiCambiati = {testo: "white",sfondo: "red", scritta: "ISCRITTO"};
- div.addEventListener("click", function () {
- if (getComputedStyle(this).color === "rgb(0, 0, 0)")
- cambiaAspetto(this, datiCambiati);
- else
- cambiaAspetto(this, datiOriginali);
- // if (getComputedStyle(this).color === "rgb(0, 0, 0)")
- // {
- // this.style.backgroundColor = "red";
- // this.style.color = "white";
- // this.textContent = "ISCRITTO";
- // }
- // else
- // {
- // this.style.backgroundColor = "lightgray";
- // this.style.color = "black";
- // this.textContent = "ISCRIVITI";
- // }
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement