Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="styles.css">
    <script src="https://kit.fontawesome.com/7dd562e58e.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://bootswatch.com/4/yeti/bootstrap.min.css">
</head>
<body>
    <div class="container">

        <div class="form-container">
           
            <form action="" class="form">
            

                <div class="form-group">

                    <h1>a message you would like to pass</h1>
                    <input name="name" type="text"class="form-control" id="input-btn"/>
                    <div class="btn-form">

                            <button class="btn-click">click me</button>

                            <div class="last-msg-div">

                                last message delivered
                            </div>
                            <div class="submit-msg">

                                hello world
                            </div>


                    </div>
                    

                </div>

           


            </form>
        </div>


    </div>
    <script src="script.js"></script>
</body>
</html>
              
            
!

CSS

              
                /* *{
    margin:0;
    padding:0;
    box-sizing: border-box;
} */
html, body { 
    
    
    min-height: 100vh; 
    min-width: 100vw;
    background:hsl(192, 100%, 50%);}

/* body{
    background:hsl(192, 100%, 50%);
    height:100vh;
    width: 100vw;
    background-size: cover;
    background-position: center;
} */

.container{
    background:hsl(192, 100%, 50%);
    min-height: 100vh; 
    min-width: 100vw;
    display:flex;
    justify-content: center;
    align-items: center;

    
}

.form-container{
    background:#e6e6e6;
    height:400px;
    width:800px;
    padding:0px 28px;
}

.form-container h1{
    text-align:center;
    margin-top:30px;
    text-transform: capitalize;
}

.btn-click{
    text-align: center;
}


.btn-form{
    margin-top:20px;
    text-align: center;
}

.btn-click{
    padding:10px 30px;
    background:hsl(192, 100%, 50%);
    text-transform: capitalize;
    font-size:19px;
    border-radius:9px;
    color:#fff;
    transition: all .4s ease-in;
    cursor:pointer;
}

.btn-click:hover{
    background:hsl(240, 100%, 65%);
    color:black;
}

.last-msg-div{
    margin-top:16px;
    font-size:40px;
    font-weight:800;
    text-transform: capitalize;

}


.submit-msg{
    margin-top:16px;
    font-size:39px;
    text-transform:capitalize;
    font-weight: 700;
    color:hsl(192, 100%, 50%);
}
              
            
!

JS

              
                const btn=document.querySelector('.btn-click');


const inputBtn=document.querySelector('#input-btn');

btn.addEventListener('click',function(e){

    if(inputBtn.value==""){
        e.preventDefault();
        // console.log("Please enter a value")
        showAlert("Please enter a value","danger");

    }else{
    e.preventDefault();
    // alert("laff");
    console.log(inputBtn.value );
    document.querySelector('.submit-msg').innerHTML=inputBtn.value;
    inputBtn.value="";
}})


function showAlert(message,className){
    const div=document.createElement('div');
    div.className=`alert alert-${className}`;
    div.appendChild(document.createTextNode(message));
    // const container=document.querySelector('.form-container');
    // const form=document.querySelector('#book-form');

    const formGroup=document.querySelector('.form-group');
    const inputBtn=document.querySelector('#input-btn');
    formGroup.insertBefore(div,inputBtn);
    setTimeout(function(){
        document.querySelector('.alert').remove();
     },3000)


}
              
            
!
999px

Console