avr39-ripe

helloAdvCSSFlex

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