
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
How to create a full screen search box with CSS and JavaScript?
Following is the code to create a full screen search box with CSS and JavaScript −
Example
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/fontawesome.min.css"> <style> body { font-family: Arial; } * { box-sizing: border-box; } .showBtn { background: #008b0c; border: none; color:white; padding: 10px 15px; font-size: 20px; cursor: pointer; opacity: 0.8; } .showBtn:hover { opacity: 1; } .overlaySearch { height: 100%; width: 100%; display: none; position: fixed; z-index: 1; top: 0; left: 0; background-color: rgba(132, 150, 155, 0.747); } .searchBar { position: relative; top: 46%; width: 80%; text-align: center; margin-top: 30px; margin: auto; } .overlaySearch .hideBtn { position: absolute; top: 20px; right: 45px; font-size: 60px; cursor: pointer; color: rgb(255, 0, 0); opacity: 0.8; } .overlaySearch .hideBtn:hover { opacity: 1; } .overlaySearch input[type=text] { padding: 15px; font-size: 17px; border: none; float: left; width: 80%; background: white; } .overlaySearch input[type=text]:hover { background: #f1f1f1; } .overlaySearch button { float: left; width: 20%; padding: 15px; background: rgb(54, 21, 241); font-size: 17px; border: none; color:white; cursor: pointer; opacity: 0.8; } .overlaySearch button:hover { opacity: 1; } </style> </head> <body> <div class="overlaySearch" > <span class="hideBtn">×</span> <div class="searchBar"> <form > <input type="text" placeholder="Search Here.." "> <button type="submit"><i class="fa fa-search"></i></button> </form> </div> </div> <h1>Fullscreen Search Example</h2> <button class="showBtn">Open Search Box</button> <h2>Click on the above button to open search box in full screen</h2> <script> document.querySelector('.hideBtn').addEventListener('click',hideSearch); document.querySelector('.showBtn').addEventListener('click',showSearch); function showSearch() { document.querySelector('.overlaySearch').style.display = "block"; } function hideSearch() { document.querySelector('.overlaySearch').style.display = "none"; } </script> </body> </html>
Output
The above code will produce the following output −
On clicking the open search box button −
- Related Articles
- How to create a full screen overlay navigation menu with CSS and JavaScript?
- How to create a full screen video background with CSS?
- How to create a Modal Box with CSS and JavaScript?
- How to create full-page tabs with CSS and JavaScript?
- How to create a flip box with CSS?
- How to create and apply CSS to JavaScript Alert box?
- How to create a search button with CSS?
- How to create a split screen (50/50) with CSS?
- Create a transparent box with CSS
- How to create a full-page background image with CSS?
- How to create a dynamic search box in ReactJS?
- How to set full-screen iframe with height 100% in JavaScript?
- How to Handle CSS in Browser Full-Screen Mode?
- How to create an animated search form with CSS?
- How to Create a Comment Box with a Containing Text Using CSS

Advertisements