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

जावास्क्रिप्ट के साथ किसी एलिमेंट की टॉप पोजिशन कैसे सेट करें?


टॉप पोजिशन सेट करने के लिए, जावास्क्रिप्ट में top प्रॉपर्टी का उपयोग करें। जावास्क्रिप्ट के साथ किसी डिव की टॉप पोजिशन सेट करना सीखने के लिए निम्न कोड चलाकर देखें:

उदाहरण

<!DOCTYPE html> <html>    <head>       <style>          #myID {             position: absolute;          }       </style>    </head>    <body>       <button onclick="display()">टॉप पोजिशन सेट करें</button>       <div id = "myID">          यह डेमो टेक्स्ट है! यह डेमो टेक्स्ट है!       </div>       <script>          function display() {             document.getElementById("myID").style.top = "100px";          }       </script>    </body> </html>

  1. - JavaScript से एलिमेंट का शीर्ष मार्जिन कैसे सेट करें?

    उदाहरण marginTop प्रॉपर्टी से एलिमेंट का शीर्ष मार्जिन सेट करें। <!DOCTYPE html> <html> <head> <style> #myID { border: 2px solid #000000; } </style> </head> <body> <div id=myID>यह डेमो टेक्स्ट है।</div><br

  1. - JavaScript से एलिमेंट का निचला मार्जिन कैसे सेट करें?

    उदाहरण marginBottom प्रॉपर्टी से एलिमेंट का निचला मार्जिन सेट करें। <!DOCTYPE html> <html> <body> <p id=myID>यह डेमो टेक्स्ट है।</p> <button type=button onclick=display()>निचला मार्जिन सेट करें</button> <script> function display() {

  1. - JavaScript से एलिमेंट के सभी मार्जिन्स एक साथ कैसे सेट करें?

    उदाहरण margin शॉर्टहैंड प्रॉपर्टी से चारों मार्जिन एक साथ सेट करें। <!DOCTYPE html> <html> <body> <button type=button onclick=display()>चारों मार्जिन सेट करें</button> <p id=myID>यह डेमो टेक्स्ट है।</p> <script> function display() {