Computer >> कंप्यूटर ट्यूटोरियल >  >> प्रोग्रामिंग >> CSS

CSS से फिक्स्ड मेनू कैसे बनाएं?


CSS से फिक्स्ड मेनू बनाने का कोड निम्नलिखित है:

उदाहरण

<!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> body{    margin:0px;    margin-top:60px;    padding: 0px; } nav{    position: fixed;    top: 0;    width: 100%;    background-color: rgb(39, 39, 39);    overflow: auto;    height: auto; } .links {    display: inline-block;    text-align: center;    padding: 14px;    color: rgb(178, 137, 253);    text-decoration: none;    font-size: 17px; } .links:hover {    background-color: rgb(100, 100, 100); } .selected{    background-color: rgb(0, 18, 43); } </style> </head> <body> <nav> <a class="links selected" href="#"> Home</a> <a class="links" href="#"> Login</a> <a class="links" href="#"> Register</a> <a class="links" href="#"> Contact Us</a> <a class="links" href="#">More Info</a> </nav> <div class="sample-content"> <h1>Here are some headers</h1> <h2>Here are some headers</h2> <h3>Here are some headers</h3> <h4>Here are some headers</h4> <h1>Here are some headers</h1> <h2>Here are some headers</h2> <h3>Here are some headers</h3> <h4>Here are some headers</h4> </div> </body> </html>

आउटपुट

यह निम्नलिखित आउटपुट उत्पन्न करेगा:

CSS से फिक्स्ड मेनू कैसे बनाएं?

जब टेक्स्ट स्क्रीन की ऊंचाई से अधिक होगा तो टेक्स्ट नेवबार के नीचे स्क्रॉल होगा जैसे नीचे दिखाया गया है:

CSS से फिक्स्ड मेनू कैसे बनाएं?


  1. CSS से फिक्स्ड/स्टिकी फुटर कैसे बनाएं? CSS से फिक्स्ड/स्टिकी फुटर कैसे बनाएं?

    CSS से फिक्स्ड फुटर बनाने के लिए, कोड निम्नानुसार है -उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style>    body{       font-family: 'Segoe UI', Tahoma, Ge

  1. CSS से तीर कैसे बनाएं? CSS से तीर कैसे बनाएं?

    CSS से तीर बनाने के लिए, कोड निम्नानुसार है -उदाहरण<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    body {       font-family: "Segoe UI", Tahoma, Geneva

  1. CSS के साथ ऑन-स्क्रॉल फिक्स्ड नेविगेशन बार कैसे बनाएं CSS के साथ ऑन-स्क्रॉल फिक्स्ड नेविगेशन बार कैसे बनाएं

    परिचय CSS position प्रॉपर्टी को निर्दिष्ट करके, हम CSS का उपयोग करके एक फिक्स्ड नेविगेशन बार बना सकते हैं जो स्क्रॉल पर फिक्स्ड हो जाता है। पोजिशन प्रॉपर्टी सिंटैक्स selector { position: static | relative | absolute | fixed | sticky; } उदाहरण: स्टिकी नेविगेशन बार = sticky) { nav.classLi