शैली प्रदर्शन संपत्ति
उदाहरण
प्रदर्शित नहीं होने के लिए एक <div> तत्व सेट करें:
document.getElementById("myDIV").style.display = "none";
परिभाषा और उपयोग
प्रदर्शन गुण तत्व के प्रदर्शन प्रकार को सेट या लौटाता है।
HTML में तत्व ज्यादातर "इनलाइन" या "ब्लॉक" तत्व होते हैं: एक इनलाइन तत्व में बाईं और दाईं ओर तैरती हुई सामग्री होती है। एक ब्लॉक तत्व पूरी लाइन को भरता है, और इसके बाईं या दाईं ओर कुछ भी प्रदर्शित नहीं किया जा सकता है।
प्रदर्शन गुण लेखक को किसी तत्व को दिखाने या छिपाने की भी अनुमति देता है। यह दृश्यता संपत्ति के समान है। हालांकि, यदि आप सेट करते हैं display:none
, तो यह पूरे तत्व को छुपाता है, जबकि visibility:hidden
इसका मतलब है कि तत्व की सामग्री अदृश्य होगी, लेकिन तत्व अपनी मूल स्थिति और आकार में रहता है।
युक्ति: यदि कोई तत्व एक ब्लॉक तत्व है, तो इसके प्रदर्शन प्रकार को भी फ्लोट संपत्ति के साथ बदला जा सकता है।
ब्राउज़र समर्थन
Property | |||||
---|---|---|---|---|---|
display | Yes | Yes | Yes | Yes | Yes |
वाक्य - विन्यास
प्रदर्शन संपत्ति लौटाएं:
object.style.display
प्रदर्शन गुण सेट करें:
object.style.display = value
सम्पत्ति की कीमत
Value | Description |
---|---|
block | Element is rendered as a block-level element |
compact | Element is rendered as a block-level or inline element. Depends on context |
flex | Element is rendered as a block-level flex box. New in CSS3 |
inline | Element is rendered as an inline element. This is default |
inline-block | Element is rendered as a block box inside an inline box |
inline-flex | Element is rendered as a inline-level flex box. New in CSS3 |
inline-table | Element is rendered as an inline table (like <table>), with no line break before or after the table |
list-item | Element is rendered as a list |
marker | This value sets content before or after a box to be a marker (used with :before and :after pseudo-elements. Otherwise this value is identical to "inline") |
none | Element will not be displayed |
run-in | Element is rendered as block-level or inline element. Depends on context |
table | Element is rendered as a block table (like <table>), with a line break before and after the table |
table-caption | Element is rendered as a table caption (like <caption>) |
table-cell | Element is rendered as a table cell (like <td> and <th>) |
table-column | Element is rendered as a column of cells (like <col>) |
table-column-group | Element is rendered as a group of one or more columns (like <colgroup>) |
table-footer-group | Element is rendered as a table footer row (like <tfoot>) |
table-header-group | Element is rendered as a table header row (like <thead>) |
table-row | Element is rendered as a table row (like <tr>) |
table-row-group | Element is rendered as a group of one or more rows (like <tbody>) |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
टेक्निकल डिटेल
डिफ़ॉल्ट मान: | इन - लाइन |
---|---|
प्रतिलाभ की मात्रा: | एक स्ट्रिंग, एक तत्व के प्रदर्शन प्रकार का प्रतिनिधित्व करता है |
सीएसएस संस्करण | सीएसएस 1 |
और ज्यादा उदाहरण
उदाहरण
प्रदर्शन गुण और दृश्यता गुण के बीच अंतर:
function demoDisplay() {
document.getElementById("myP1").style.display = "none";
}
function demoVisibility() {
document.getElementById("myP2").style.visibility = "hidden";
}
उदाहरण
किसी तत्व को छिपाने और दिखाने के बीच टॉगल करें:
function myFunction() {
var x = document.getElementById('myDIV');
if (x.style.display === 'none') {
x.style.display = 'block';
} else {
x.style.display = 'none';
}
}
उदाहरण
"इनलाइन", "ब्लॉक" और "कोई नहीं" के बीच अंतर:
function myFunction(x) {
var whichSelected = x.selectedIndex;
var sel = x.options[whichSelected].text;
var elem = document.getElementById("mySpan");
elem.style.display = sel;
}
उदाहरण
<p> तत्व का प्रदर्शन प्रकार लौटाएं:
alert(document.getElementById("myP").style.display);
संबंधित पृष्ठ
सीएसएस ट्यूटोरियल: सीएसएस प्रदर्शन और दृश्यता
सीएसएस संदर्भ: संपत्ति प्रदर्शित करें
❮ स्टाइल ऑब्जेक्ट