以下のコードは、自動的にYスクロールする2つのネストされたdivを示しています。CSSネストされたスクロールバーとダイナミックコンテンツが100%の幅で重複しています
内側のスクロールバーを表示し、内側のdivを100%の幅に保つCSSソリューションはありますか?
div {
background: rgba(0, 0, 0, 0.2);
width: 200px;
height: 400px;
overflow-y: auto
}
#outer { height: 400px; }
#inner { height: 200px; }
button { float: right; color: #F60}
<button onclick="document.getElementById('outerContent').innerHTML='smaller content does not need to scroll #inner should should still be 100% width of #outer'">TRY WITH SMALLER CONTENT</button>
<div id='outer'>
<span id='outerContent'>Some long content which causes scroll Some long content which causes scroll Some long content which causes scroll Some long content which causes scroll Some long content which causes scroll Some long content which causes scroll Some long content which
causes scroll Some long content which causes scroll Some long content which causes scroll Some long content which causes scroll Some long content which
causes scroll</span>
<div id='inner'>INNER DIV ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR INNER DIV ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR INNER DIV ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR INNER DIV ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR INNER DIV
ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR INNER DIV ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR INNER DIV ALSO NEEDS TO SCROLL BUT I CANT SEE THE SCROLLBAR
</div>
</div>
<ボタンのonclick = "のdocument.getElementById( 'outerContent')のinnerHTML = '小さいコンテンツが#innerをスクロールする必要がない依然として#outerの100%の幅であるべきであるべきです'。 document.getElementById( 'inner')。style.overflow = 'hidden' ">より小さなコンテンツを試す –