free source of html css java script code
image
code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: arial, sans-serif;
}
nav {
background-color: #333;
color: white;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
}
.logo {
font-size: 20px;
font-weight: bold;
}
.right-section {
display: flex;
align-items: center;
gap: 10px;
}
.search-btn {
background-color: #555;
color: white;
border: none;
padding: 5px 10px;
cursor: pointer;
border-radius: 4px;
}
.menu {
display: flex;
gap: 20px;
}
.toggle-btn {
display: none;
font-size: 24px;
background: none;
border: none;
color: white;
cursor: pointer;
}
.menu a{
text-decoration: none;
color: black;
}
@media (max-width: 350px) {
.menu {
display: none;
flex-direction: column;
background-color: #444;
width: 100%;
padding:10px;
}
.menu.show {
display: flex;
}
.toggle-btn {
display: block;
}
.right-section {
flex-direction: row-reverse;
gap: 5px;
}
}
</style>
</head>
<body>
<nav>
<div class="logo">Rishu</div>
<div class="right-section">
<button class="search-btn">search</button>
<button class="toggle-button" onclick="togglemenu()">☰</button>
</div>
</div>
</nav>
<div class="menu" id="menu">
<a href="#">Home</a>
<a href="#">Favourite</a>
<a href="#">popular</a>
</div>
<script>
function togglemenu(){
const menu = document.getElementById('menu');
menu.classList.toggle('show');
}
</script>
</body>
</html>
thanks
Comments
Post a Comment