avr39ripe

helloAdvCSS

Sep 18th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.18 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.     <head>
  4.         <meta charset="UTF-8">
  5.         <title>Hello,world!</title>
  6.         <style>
  7.             html,
  8.             body {
  9.                 display: flex;
  10.                 height: 100%;
  11.                 align-items: center;
  12.                 justify-content: center;
  13.             }
  14.             .centered {
  15.                display: flex;
  16.                flex-direction: column;
  17.                align-items: center;
  18.                justify-content: center;
  19.                padding: 50px;
  20.                background-color: orange;
  21.                border: 2px solid orange;
  22.                border-radius: 8px;
  23.             }
  24.             #main {
  25.                 display: none;
  26.             }
  27.             #disp {
  28.                 display: flex;
  29.             }
  30.            
  31.             button,
  32.             input{
  33.                 background-color: orangered;
  34.                 border-radius: 28px;
  35.                 border:1px solid red;
  36.                 font-size: 1.2em;
  37.                 font-weight: bold;
  38.                 padding: 16px 31px;
  39.                 margin: 10px;
  40.             }
  41.            
  42.             input {
  43.                 background-color: orange;
  44.                 border:2px solid red;
  45.             }
  46.            
  47.             button:hover {
  48.                 background-color: red;
  49.             }
  50.             button:active {
  51.                 position:relative;
  52.                 top: 2px;
  53.             }
  54.             button,input:focus {
  55.                 outline: 0;
  56.             }
  57.         </style>
  58.     </head>
  59.     <body>
  60.         <div class="centered" id="main">
  61.             <h1 id="greeter">Hello, Stranger!</h1>
  62.             <input id="nameIn" type="text">
  63.             <button id="btn">Say hello!</button>
  64.         </div>
  65.         <div class="centered" id="disp">
  66.             <button id="showBtn">SHOW!</button>
  67.         </div>
  68.         <script>
  69.             showBtn.addEventListener( "click" , function() {main.style.display='flex'; disp.style.display='none'});
  70.             greeter.addEventListener( "click" , function() {main.style.display='none'; disp.style.display='flex'});
  71.             btn.addEventListener( "click" , function() {greeter.innerText = "Hello, " + (nameIn.value !="" ? nameIn.value + "!" : " John Doe!");});
  72.         </script>
  73.     </body>
  74. </html>
  75.  
Advertisement
Add Comment
Please, Sign In to add comment