2016-10-17 9 views
5

मैं नेस्टेड div के नीचे एक div कैसे रखूं? अभी तीसरा div (.box3) दूसरे div को ओवरलैप करता है जब मैं इसे दूसरे div (.box2) के नीचे दिखाना चाहता हूं। कृपया उदाहरण देखें: https://jsfiddle.net/662fwmq5/एक नेस्टेड div के नीचे एक div कैसे रखें?

.box1 { 
 
    width: 50%; 
 
    height: 200px; 
 
    padding: 15px; 
 
    background-color: red; 
 
    margin: 0 auto; 
 
} 
 
.box2 { 
 
    width: 80%; 
 
    padding: 15px; 
 
    background-color: blue; 
 
    color: #fff; 
 
    margin: 0 auto; 
 
    margin-top: 100px; 
 
} 
 
.box3 { 
 
    background-color: #ccc; 
 
    text-align: center; 
 
}
<div class="box1"> 
 
    Box 1 
 
    <div class="box2"> 
 
    Fixed income, currency, and commodities revenue was $2.65 billion ($2.21 billion expected), up 39% thanks to stronger performance in credit products, especially mortgages, as well as in rates products and client financing. Equities revenue came in at 
 
    $954 million ($1.03 billion expected), down 17% because of lower client activity in cash and derivatives, which the firm said reflected lower market volatility. 
 
    </div> 
 
</div> 
 

 
<div class="box3"> 
 
    More than 14,000 seasonal positions were transitioned to regular, full-time roles after the holidays last year, and the company expects to increase that number this year, Amazon said on Thursday. 
 
</div>

मेरे मुद्दा आगे बढ़ाया जाता है जब स्क्रीन आकार सीमित कर देता है। मैं तीसरे div (.box3) को स्क्रीन आकार में परिवर्तनों का जवाब देना चाहता हूं ताकि तीसरा div हमेशा दूसरे div (.box2) के नीचे दिखाई दे।

उत्तर

1

आपने box1 के लिए एक निश्चित ऊंचाई तय की है - यही कारण है कि निम्न div नेस्टेड सामग्री को ओवरलैप कर रहा है।

तो heightbox1 से हटा दें और वहाँ तुम जाओ:

.box1 { 
 
\t width: 50%; 
 
\t /*height: 200px;*/ 
 
\t padding: 15px; 
 
\t background-color: red; 
 
\t margin: 0 auto; 
 
} 
 

 
.box2 { 
 
\t width: 80%; 
 
\t padding: 15px; 
 
\t background-color: blue; 
 
\t color: #fff; 
 
\t margin: 0 auto; 
 
\t margin-top: 100px; 
 
} 
 

 
.box3 { 
 
\t background-color: #ccc; 
 
\t text-align: center; 
 
}
<body> 
 
\t <div class="box1"> 
 
\t Box 1 
 
\t \t <div class="box2"> 
 
\t \t Fixed income, currency, and commodities revenue was $2.65 billion ($2.21 billion expected), up 39% thanks to stronger performance in credit products, especially mortgages, as well as in rates products and client financing. 
 
\t \t Equities revenue came in at $954 million ($1.03 billion expected), down 17% because of lower client activity in cash and derivatives, which the firm said reflected lower market volatility. 
 
\t \t </div> 
 
\t </div> 
 

 
\t <div class="box3"> 
 
\t \t More than 14,000 seasonal positions were transitioned to regular, full-time roles after the holidays last year, and the company expects to increase that number this year, Amazon said on Thursday. 
 
\t </div> 
 
</body>

आप ऊंचाई को बदल नहीं सकते हैं, तो आप यह overflow-y: auto का उपयोग कर अतिप्रवाह कर सकते हैं:

.box1 { 
 
\t width: 50%; 
 
\t height: 200px; 
 
    overflow-y: scroll; 
 
\t padding: 15px; 
 
\t background-color: red; 
 
\t margin: 0 auto; 
 
} 
 

 
.box2 { 
 
\t width: 80%; 
 
\t padding: 15px; 
 
\t background-color: blue; 
 
\t color: #fff; 
 
\t margin: 0 auto; 
 
\t margin-top: 100px; 
 
} 
 

 
.box3 { 
 
\t background-color: #ccc; 
 
\t text-align: center; 
 
}
<body> 
 
\t <div class="box1"> 
 
\t Box 1 
 
\t \t <div class="box2"> 
 
\t \t Fixed income, currency, and commodities revenue was $2.65 billion ($2.21 billion expected), up 39% thanks to stronger performance in credit products, especially mortgages, as well as in rates products and client financing. 
 
\t \t Equities revenue came in at $954 million ($1.03 billion expected), down 17% because of lower client activity in cash and derivatives, which the firm said reflected lower market volatility. 
 
\t \t </div> 
 
\t </div> 
 

 
\t <div class="box3"> 
 
\t \t More than 14,000 seasonal positions were transitioned to regular, full-time roles after the holidays last year, and the company expects to increase that number this year, Amazon said on Thursday. 
 
\t </div> 
 
</body>

+1

धन्यवाद। यह सहायक था। –

0

यू उपयोग कर सकते हैं एक containerdiv और box1 और box2 अंदर और box3 डाल यह बाहर सबसे आसान और प्रासंगिक होगा ..

+0

धन्यवाद। यह भी सहायक है। –

+0

आपका स्वागत है ..... –