69 lines
1.9 KiB
HTML
69 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Responsive Page with Bootstrap</title>
|
|
<!-- Bootstrap CSS -->
|
|
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">
|
|
<style>
|
|
/* Centering the content */
|
|
body {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
}
|
|
|
|
/* Styling the results box */
|
|
#results-box {
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-6 offset-md-3">
|
|
<!-- Search Bar -->
|
|
<input type="text" class="form-control" id="searchInput" placeholder="Type something and press Enter">
|
|
|
|
<!-- Results Box -->
|
|
<div id="results-box" class="mt-3"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bootstrap JS and Popper.js (required for Bootstrap) -->
|
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
|
|
|
|
<!-- Custom JavaScript for handling the search -->
|
|
<script>
|
|
document.getElementById('searchInput').addEventListener('keyup', function (event) {
|
|
if (event.key === 'Enter') {
|
|
handleSearch();
|
|
}
|
|
});
|
|
|
|
function handleSearch() {
|
|
var searchInput = document.getElementById('searchInput');
|
|
var searchTerm = searchInput.value;
|
|
|
|
if (searchTerm.trim() !== '') {
|
|
// Append result to the results box
|
|
var resultsBox = document.getElementById('results-box');
|
|
resultsBox.innerHTML += '<p class="alert alert-success">Result: ' + searchTerm + '</p>';
|
|
|
|
// Clear the search input
|
|
searchInput.value = '';
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|