यह बिल्कुल असंभव नहीं है, और आपको जावास्क्रिप्ट की आवश्यकता नहीं है। यदि आप उस ब्राउज़र की परवाह करते हैं तो आपको कुछ आईई 6 विशिष्ट हैक्स की आवश्यकता है।
लेआउट की कुंजी यह तथ्य है कि आप एक या अधिक किनारे की स्थिति को एक पूरी तरह से स्थित तत्व पर सेट कर सकते हैं। http://www.alistapart.com/articles/conflictingabsolutepositions/
यहाँ एक डेमो है: http://www.spookandpuff.com/examples/2col2section.html
और स्रोत:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>2 col, 2 section layout.</title>
<style type="text/css" media="screen">
#leftColumn {
position:absolute;
top:10px;
bottom:10px;
left:10px;
width:400px;
}
#rightColumn {
position:absolute;
top:10px;
bottom:10px;
right:10px;
left:410px;/* This must equal the total width of the #leftColumn, incl padding, border, margin, etc. */
}
.topSection{
position:absolute;
top:10px;
height:120px;
left:10px;
right:10px;
padding:10px;
}
.bottomSection{
position:absolute;
bottom:10px;
top:160px; /* This must equal the total height of the .topSection, incl padding, border, margin, etc. */
left:10px;
right:10px;
padding:10px;
overflow-y:auto;
}
/* Debug styles */
body {background-color:#CCC;}
div {border:1px solid #FFF;}
#leftColumn {background-color:#7EF4B0;}
#rightColumn {background-color:#EEF4A7;}
#leftColumn .topSection{background-color:#56A97A;}
#rightColumn .topSection{background-color:#D6D06D;}
</style>
</head>
<body>
<div id="leftColumn">
<div class="topSection">
<p>Left column, top section.</p>
</div>
<div class="bottomSection">
<p>Left column, bottom section.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<div id="rightColumn">
<div class="topSection">
<p>Right column, top section.</p>
</div>
<div class="bottomSection">
<p>Right column, bottom section.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</body>
</html>
कुछ तरकीबें हैं: सबसे पहले, मैं केवल फ़ायरफ़ॉक्स में इस परीक्षण किया आप को देने के लिए यहाँ तकनीक पर एक अच्छा लेख है सामान्य विचार - आईई के लिए कुछ आवश्यक फिक्स्ड हैं जिन्हें मैंने नहीं जोड़ा है: विवरण के लिए आलेख ऊपर सूची को अलग करें।
मैंने विचार को चित्रित करने के लिए सभी बक्से के आस-पास 10px अतिरिक्त स्थान की अनुमति दी है - आप शायद इन्हें वास्तविक लेआउट में 0 पर सेट कर देंगे।
आप जैसे कुछ नियमों के साथ अलग ढंग से स्तंभों के बीच .topSection की ऊंचाई सेट कर सकते हैं:
#leftColumn .topSection {height:xxx}
#leftColumn .bottomSection {top:xxx}
#rightColumn .topSection {height:yyy}
#rightColumn .bottomSection {top:yyy}
मैं की चौड़ाई निर्दिष्ट करने के लिए एक वर्ग के साथ एक कंटेनर (या शरीर टैग पर एक वर्ग) का प्रयोग करेंगे बाएं कॉलम, जैसे कुछ:
#container.narrow #leftColumn {width:100px}
#container.medium #leftColumn {width:200px}
#container.wide #leftColumn {width:400px}
जो आपको चौड़ाई 'टेम्पलेट्स' के सेट को परिभाषित करने की अनुमति देता है, जिसके बीच आप स्विच कर सकते हैं।
बहुत सीधे आगे होना चाहिए, जब तक बाएं और दाएं स्क्रीन चौड़ाई का अनुपात हो। क्या मैं आपके प्रयासों में से एक देख सकता हूं? – edl
आप किस ब्राउजर का समर्थन कर रहे हैं? – drusnov
यदि आप कुछ काम करने के लिए तैयार हैं तो बहुत आसान होना चाहिए। – User