2016-11-08 12 views
6

enter image description hereबूटस्ट्रैप 4 के साथ एक निश्चित साइडबार लेआउट कैसे बनाएं?

मैं स्क्रीनशॉट बूटस्ट्रैप 4 का उपयोग की तरह एक लेआउट बनाने के लिए कोशिश कर रहा हूँ, लेकिन मैं साइडबार तय कर रहे हैं और एक ही समय में इस लेआउट को प्राप्त करने के साथ कुछ समस्या आ रही है।

एक बुनियादी उदाहरण के साथ जा रहे हैं:

<div class="container"> 
    <div class="row"> 
    <div class="col-m-4" id="sticky-sidebar"> 
     Sidebar 
    </div> 
    <div class="col-m-8" id="main"> 
     Main Area 
    </div> 
    </div> 
</div 

यह इस लेआउट प्राप्त करना संभव है लेकिन चीजों को मुश्किल हो एक बार मैं घोषणा: एक बार मैं साइडबार चिपचिपा बनाने

.sidebar { 
position: fixed // or absolute 
} 

, मुख्य div के आगे साइडबार के बजाय दिखाई देने लगते हैं। बेशक कुछ मार्जिन घोषित करना और इसे वापस मूल स्थिति में धक्का देना संभव है लेकिन यह प्रतिक्रियाओं के लिए चीजों को जटिल बनाता है।

मुझे लगता है कि मुझे कुछ याद आ रहा है, मैंने बूटस्ट्रैप 4 दस्तावेज पढ़ा लेकिन मुझे इस लेआउट को प्राप्त करने का एक आसान तरीका नहीं मिला।

उत्तर

4

ऐसा कुछ?

#sticky-sidebar { 
 
position:fixed; 
 
max-width: 20%; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class="container"> 
 
    <div class="row"> 
 
    <div class="col-xs-4"> 
 
     <div class="col-xs-12" id="sticky-sidebar"> 
 
     Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
     </div> 
 
    </div> 
 
    <div class="col-xs-8" id="main"> 
 
     Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    </div> 
 
    </div> 
 
</div

+0

आप अपने साइडबार सामग्री के लिए कुछ lorem ipsum जोड़ देते हैं तो आप देख सकते हैं कि मेरी प्रारंभिक समस्या यह स्निपेट में निर्मित हो जाता है। चूंकि हम एक निश्चित स्थिति घोषित कर रहे हैं, साइडबार ग्रिड सिस्टम का सम्मान करना बंद कर देता है। – cinnaroll45

+0

मैंने साइडबार – GvM

+0

पर जोड़ा गया 'अधिकतम चौड़ाई: 20% 'कोड संपादित किया है, हां, अधिकतम चौड़ाई को कंटेनर घोषित करने से समस्या ठीक हो जाती है। धन्यवाद! – cinnaroll45

-1

मेरे संस्करण:

div#dashmain { margin-left:150px; } 
div#dashside {position:fixed; width:150px; height:100%; } 
<div id="dashside"></div> 
<div id="dashmain">       
    <div class="container-fluid"> 
     <div class="row"> 
      <div class="col-md-12">Content</div> 
     </div>    
    </div>   
</div> 
संबंधित मुद्दे