Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">

<div class="container">
		<h1>Search for your Soulmate</h1>

		<div class="search-field">
				<i id="search-btn" class="fas fa-search"></i>
				<input id="search" type="text" placeholder="">
				<p id="tip">Hit Enter to Search</p>
		</div>
</div>
              
            
!

CSS

              
                * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: sans-serif;
    background: #242424;
}

body {
    height: 100vh;
    color: #eee;
    display: grid;
    justify-content: center;
    align-items: center;
}

.container {
    text-align: center;
}

h1 {
    margin: 1.5rem;
}

input {
    background: #000;
    width: 4rem;
    height: 4rem;
    margin: 1.5rem;
    padding: 1.5rem;
    border-radius: 2rem;
    border: 2px solid cornflowerblue; 
    cursor: pointer;  
    outline: none;
    font-size: 1.5rem;
    color: #eee;
    transition: width 1s ease;
}

i.fas {
    font-size: 2rem;
		color: cornflowerblue;
    margin: 2.5rem;
    position: absolute;
    cursor: pointer;
}

p#tip {
    text-align: left;
    margin-left: 6rem;
    visibility: hidden;
    opacity: 0;
    transition: all 2s;
    color: cornflowerblue;
}
              
            
!

JS

              
                const searchBtn = document.getElementById('search-btn');
const search = document.getElementById('search');
const tip = document.getElementById('tip');

//  variables for the typewritter effect
let i = 0;
let message = 'Girls who love Web Devs';
let speed = 150;

//  adding eventlistener for click on the search button for expanding its width
searchBtn.addEventListener('click', () => {
    search.style.width = '90%';
    search.style.paddingLeft = '4rem';
    //  to change the sursor type back to text after expanding
    search.style.cursor = 'text';
    //  to focus the input after expanding and awoid to have to click for input
    search.focus();

    //  typewritter effect on placeholder
    typeWritter();

});

//  function for the typewritter effect
function typeWritter() {
    if (i < message.length) {
        msg = search.getAttribute('placeholder') + message.charAt(i);
        search.setAttribute('placeholder', msg);
        i++;
        setTimeout(typeWritter, speed);
    }
}

//  to make the tooltip appear on the start of typing in the input
search.addEventListener('keydown', () => {
    tip.style.visibility = 'visible';
    tip.style.opacity = 1;
});
              
            
!
999px

Console