2017-04-13 2 views
0

私はスライダーが私のウェブサイト上で正しく動作の前/後に取得しようとしています。私はほとんどそこにいるが、DIVはモバイルブラウザで適切に拡大縮小されていない。それは私のスマートフォン画面の幅を超えて広がっています。スケール部門からスマートフォン幅まで

Here's a link to the website page I'm working on

途中で、前/後スライダーのある偏光子セクションが表示されます。デスクトップブラウザでは正常に見えますが、モバイルでは画面幅を超えています。私のコーディングスキルはかなり弱いので、ここでは単純なものが欠けているかもしれません。

Here's where I got the Before/After code from.

私はちょうど下のCSSのセクションの一つに基本的な性質を挿入する必要があると仮定?

<meta name="viewport" content="width=device-width, initial-scale=1"> 

<style type="text/css">div.beforeandafter{ /* main container */ 
background: white; 
display: block; 
height: 630x; /* default height of main container */ 
overflow: hidden; 
position: relative; 
width: 944px; /* default width of main container */ 

}

div.before, div.after{ /* before and after DIVs within main container */ 
height: 100%; 
left: 0; 
overflow: hidden; 
position: absolute; 
top: 0; 
transition: width 0.4s ease-in-out; /* CSS transition. Actual duration set inside script (options.revealduration) */ 
width: 100%; 
z-index: 100; 

}

div.after{ 
z-index: 1; /* z-index of after div should be smaller than before's */ 

}

div.drag{ /* main div used for separating and dragging between before and after slides */ 
background: white; 
cursor: col-resize; 
display: block; 
height: 100%; 
left: 100%; 
position: absolute; 
top: 0; 
transition: left 0.4s ease-in-out; /* transition. 0.4s sets duration of drag fade in time */ 
width: 2px; /* width of drag bar separator */ 
z-index: 1001; 

}

:私はすでに頭の中にビューポートのコードを追加しました

div.drag div.draghandle{ /* handle bar within drag interface */ 
background: darkred; 
background: -moz-radial-gradient(center, ellipse cover, rgba(169,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%); 
background: -ms-radial-gradient(center, ellipse cover, rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); 
background: -o-radial-gradient(center, ellipse cover, rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); 
background: radial-gradient(ellipse at center, rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); 
background: rgb(169,3,41); 
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(169,3,41,1)), color-stop(44%,rgba(143,2,34,1)), color-stop(100%,rgba(109,0,25,1))); 
background: -webkit-radial-gradient(center, ellipse cover, rgba(169,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); 
border-radius: 2px; 
box-shadow: 0 0 5px gray; 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#a90329', endColorstr='#6d0019',GradientType=1); 
height: 20%; /* height of drag handle */ 
position: absolute; 
text-align: center; 
width: 16px; /* width of drag handle */ 

}

div.before span.caption, div.after span.caption{ /* CSS to syle SPAN caption. Optional */ 
background: black; 
bottom: 10px; 
color: white; 
display: block; 
font: bold 12px Germand; 
padding: 5px; 
position: absolute; 
right: 10px; 
width: 90px; 

}

div.before span.caption{ 
left: 10px; 
right: auto; 

}

div.before span.caption a, div.after span.caption a{ 
color: lightyellow; 
text-decoration: none; 

}最後に

は、ここでは実際のDIVです

<div class="beforeandafter" id="baf" style="width:944px; height:630px; "> 
+0

'px'の代わりに'% 'に' width'を使って、それに応じてデバイスの幅に適合させてみてください。 –

答えて

1

あなたのHTMLあなたのCSSドキュメント内のその後

<div class="beforeandafter" id="baf"> 

に、div.beforeandafterからheight: 630px;width: 944pxを削除し、padding-bottom: 66.73728814%を追加することを

<div class="beforeandafter" id="baf" style="width:944px; height:630px; "> 

変更にインラインスタイルとして定義された高さと幅を持っています

+0

それはそれをした!ご協力ありがとうございました! – Peter

+0

@Peter sweet、問題ありません:) –

関連する問題