前提・実現したいこと
jQueryを使っています。ご意見、ご回答宜しくお願い致します。
「button」のクリック
↓
「.outer」のスクロールバーの幅を測り、
↓
「.target」にその幅でボーダーを加えたい
のですが、どうしたらいいでしょうか?
html
1<button>button</button> 2 3<div class="outer"> 4 <div class="target">target</div> 5</div>
css
1body { 2 overflow: hidden; 3 margin: 0; 4 padding: 0; 5} 6.outer { 7 background: springgreen; 8 width: 100%; 9 height: 200px; 10 overflow-y: scroll; 11} 12.target { 13 background: sandybrown; 14}
###試したこと
イメージとして下記の流れになると思います。
もちろん下記は「.outer」でなく「body」の幅が対象になっているのでできないのですが…
どのようにすればいいでしょうか?
jQuery
1$( function(){ 2 $( 'button' ).click( function(){ 3 $( '.target' ).css( "border-right", "solid "+( window.innerWidth-document.body.clientWidth )+"px red" ); 4 }); 5}); 6
よろしければお試しくださいまし → https://jsfiddle.net/qb4zyamu/

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/02 10:33