Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Hello,world!</title>
- <style>
- /* .centered {
- text-align: center;
- }
- #main {
- display: none;
- }
- #disp {
- display: block;
- }*/
- html,
- body {
- display: flex;
- height: 100%;
- align-items: center;
- justify-content: center;
- }
- .centered {
- background-color: orange;
- border: 2px solid orange;
- border-radius: 8px;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 50px;
- }
- #main {
- display: none;
- }
- #disp {
- display: flex;
- }
- button,
- input{
- background-color: orangered;
- border-radius: 28px;
- border:1px solid red;
- font-size: 1.2em;
- font-weight: bold;
- padding: 16px 31px;
- margin: 10px;
- }
- button:hover {
- background-color: red;
- }
- button:active {
- position:relative;
- top: 2px;
- }
- button,input:focus {
- outline: 0;
- }
- input {
- background-color: orange;
- border:2px solid red;
- }
- </style>
- </head>
- <body>
- <div class="centered" id="main">
- <h1 id="greeter">Hello, Stranger!</h1>
- <input id="nameIn" type="text" placeholder="enter your name here">
- <button id="btn">Say hello!</button>
- </div>
- <div class="centered" id="disp">
- <button id="showBtn">SHOW!</button>
- </div>
- <script>
- btn.addEventListener( "click" , function() {greeter.innerText = "Hello, " + (nameIn.value !="" ? nameIn.value + "!" : " John Doe!");});
- showBtn.addEventListener( "click" , function() {main.style.display='flex'; disp.style.display='none'});
- greeter.addEventListener( "click" , function() {main.style.display='none'; disp.style.display='flex'});
- </script>
- </body>
- </html>
- </html>
Add Comment
Please, Sign In to add comment