में इनलाइन-ब्लॉक तत्व के 100% तक चौड़ाई को सही ढंग से खींचना मेरे पास निम्न मार्कअप है, जहां मैं ऊपर की ओर शीर्षक के दाईं ओर दाईं ओर संरेखित करने के लिए दूसरी तालिका का दायां हाथ पाने का प्रयास कर रहा हूं यह। यह आईई 8, फ़ायरफ़ॉक्स और क्रोम में काम करता है, लेकिन आईई 6/7 में तालिका पृष्ठ की चौड़ाई को भरने के लिए गलत तरीके से फैली हुई है।IE6 और IE7
मैं Trip Switch hasLayout trigger का उपयोग कर रहा हूं ताकि inline-block
आईई 6/7 में लागू हो सके।
क्या कोई जानता है कि कैसे (या यहां तक कि अगर) केवल आईई 6/7 में inline-block
के साथ प्रदर्शित रैपर तत्व की प्राकृतिक चौड़ाई को भरने के लिए तालिका प्राप्त कर सकता है?
आप http://jsbin.com/uyuva पर लाइव कोड चल रहे देख सकते हैं।
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
<style>
.wrapper {
display: inline-block;
border: 1px solid green;
}
/*
display: inline-block triggers the wrapper element to have layout for IE 6/7.
The trip switch then provides the inline component of the display behaviour.
See http://www.brunildo.org/test/InlineBlockLayout.html for more details.
*/
.wrapper {
*display: inline;
}
table {
border: 1px solid red;
}
</style>
</head>
<body>
<h1>No width on table:</h1>
<div class="wrapper">
<h2>The right hand side of the table doesn't stretch to the end of this heading</h2>
<table><tr><td>foo</td></tr></table>
</div> text
<h1>Width on table:</h1>
<div class="wrapper">
<h2>The right hand side of the table should stretch to the end of this heading</h2>
<table style="width: 100%"><tr><td>foo</td></tr></table>
</div> text
</body>
</html>
अद्यतन: यहाँ समस्या का एक और उदाहरण है, एक तालिका का उपयोग कर और एक बिल्कुल तैनात कंटेनर तत्व का उपयोग किए बिना इस बार। आप http://jsbin.com/igila4 पर चल रहे कोड को देख सकते हैं।
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
<style>
div {
position: absolute;
border: 1px solid red;
}
input {
width: 100%;
*width: 95%; /* fudge factor for IE 6/7 which don't support box-sizing */
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
textarea {
width: 400px;
}
</style>
<body>
The width of the input and textarea below should be identical.<br/>
<div>
<input value="This is an input with width 100%"><br/>
<textarea>This is a text area with width 400px.</textarea>
</div>
</body>
</html>
क्या आप तालिका को ऊपर से विशेष रूप से H2 की चौड़ाई से मिलान करने की कोशिश कर रहे हैं या H2 के बावजूद div.wrapper की चौड़ाई भरें? –
यदि एच 2 तालिका की प्राकृतिक चौड़ाई से व्यापक है तो मैं H2 की चौड़ाई से मेल खाने के लिए तालिका प्राप्त करने का प्रयास कर रहा हूं। यदि एच 2 प्राकृतिक तालिका चौड़ाई की तुलना में संकुचित है तो मुझे div.wrapper की चौड़ाई प्राकृतिक तालिका चौड़ाई के रूप में समाप्त होने की उम्मीद है। –