2017-02-13 51 views
0

ブラウザのサイズを変更すると、コンテンツが横方向に縮小されます。ブラウザでコンテンツのサイズを変更せずにフレックスサイズを変更する

display: flexjp-controlsに割り当てると完全に機能します。しかし私はflexを使うことができないようにIE9をサポートする必要があります。どのように私は同等のを行うが、IE9のサポートをしていますか?

それが現在何を参照するには、オープン開発ツール=>モバイルデバイスと私は(しかしdisplay: flexを使用せずに欲しい

https://jsfiddle.net/3ej343z4/1/

を溢れるコンテンツを見るために、解像度372×300を選択し、どのように注意してくださいいいえあふれ):

enter image description here

それが現在何:

enter image description here

HTML:

<div class="jp-sleek jp-jplayer jp-audio jp-state-volume-low"> 
    <div class="jp-gui" style="opacity: 1;"> 
    <div class="jp-controls jp-icon-controls"> 
     <button class="jp-play"><i class="fa fa-play"></i></button> 
     <div class="jp-playback-rate-bar"> 
     <div class="jp-playback-rate-bar-value" style="width: 14.2857%;"></div> 
     </div> 
     <button class="jp-repeat"><i class="fa fa-repeat"></i></button> 
     <div class="jp-progress"> 
     </div> 
     <button class="jp-full-screen"><i class="fa fa-expand"></i></button> 
     <div class="jp-title-container"><img class="jp-poster" src="https://i.ytimg.com/vi/bM7SZ5SBzyY/hqdefault.jpg"> 
     <div class="jp-title">Fade</div> 
     </div> 
    </div> 
    </div> 
</div> 

CSS:

.jp-sleek { 
    z-index: 100; 
    width: 100%; 
    font-family: "Source Sans Pro", sans-serif; 
} 

.jp-sleek .jp-gui { 
    height: 42px; 
    background-color: #e5e5e5; 
    position: relative; 
} 

.fa { 
    font-size: 24px; 
} 

.jp-sleek .jp-gui .jp-controls { 
    height: 100%; 
    position: relative; 
    font-size: 24px; 
    white-space: nowrap; 
} 

.jp-sleek .jp-gui .jp-controls button { 
    color: #000; 
    padding: 0; 
    border: none; 
    background-color: transparent; 
} 

.jp-sleek .jp-gui .jp-controls > * { 
    margin-left: 5px; 
    margin-right: 5px; 
    display: inline-block; 
    height: 100%; 
    vertical-align: top; 
} 

.jp-sleek .jp-gui .jp-playback-rate-bar { 
    background-color: #a1c1f4; 
    cursor: pointer; 
    width: 60px; 
    min-width: 30px; 
} 

.jp-sleek .jp-gui .jp-playback-rate-bar .jp-playback-rate-bar-value { 
    background-color: #71a6fc; 
    height: 100%; 
    width: 14%; 
} 

.jp-sleek .jp-gui .jp-icon-controls button { 
    min-width: 42px; 
} 

.jp-sleek .jp-gui .jp-icon-controls .jp-progress { 
    background-color: #a1c1f4; 
    width: 100%; 
    min-width: 180px; 
    max-width: 500px; 
    font-size: 20px; 
    position: relative; 
} 

.jp-sleek .jp-gui .jp-title-container { 
    font-size: 12px; 
    vertical-align: top; 
} 

.jp-audio.jp-sleek .jp-gui .jp-title-container .jp-poster { 
    max-height: 100%; 
} 

img { 
    vertical-align: middle; 
} 

.jp-sleek .jp-gui .jp-title-container .jp-title { 
    font-weight: bold; 
    max-width: 135px; 
    text-overflow: ellipsis; 
    overflow: hidden; 
    display: inline-block; 
    vertical-align: middle; 
    margin-left: 10px; 
} 

答えて

1
flexboxesのように振る舞うことができ

テーブル:私は、コードでCSSの変更をマークした

.jp-controls { 
    display: table; 
    height: inherit; /*42px from the parent*/ 
} 

.jp-controls > * { 
    height: inherit; 
    display: table-cell; 
} 

: jsfiddle:https://jsfiddle.net/3ej343z4/3/

+0

これはうまく動作します。私はちょうど表形式のデータ(または私が読んでいる)のための実際のものであるので、テーブルを使用しないことを望んでいます。私は読み込みテーブルにアクセシビリティの問題があります –

+1

CSS "' display:table' "はどの要素のセマンティクスも変更しません。 [...]エフェクトは視覚的なレイアウト効果で、CSSのドメインです。 - 詳細はこちら[こちらの説明](http://softwareengineering.stackexchange.com/questions/297807/is-the-table-tag-and-displaytable-a-functional-or-a-layout-directive) – pol

0

calc()関数を使用して、.jp-progressの幅(100% - 他のコントロールの幅の合計)を計算します。

JSFiddle

.jp-controls { 
 
    display: flex; 
 
} 
 
.jp-sleek { 
 
    z-index: 100; 
 
    width: 100%; 
 
    font-family: "Source Sans Pro", sans-serif; 
 
} 
 
.jp-sleek .jp-gui { 
 
    height: 42px; 
 
    background-color: #e5e5e5; 
 
    position: relative; 
 
} 
 
.fa { 
 
    font-size: 24px; 
 
} 
 
.jp-sleek .jp-gui .jp-controls { 
 
    height: 100%; 
 
    position: relative; 
 
    font-size: 24px; 
 
    white-space: nowrap; 
 
} 
 
.jp-sleek .jp-gui .jp-controls button { 
 
    color: #000; 
 
    padding: 0; 
 
    border: none; 
 
    background-color: transparent; 
 
} 
 
.jp-sleek .jp-gui .jp-controls > * { 
 
    margin-left: 5px; 
 
    margin-right: 5px; 
 
    display: inline-block; 
 
    height: 100%; 
 
    vertical-align: top; 
 
} 
 
.jp-sleek .jp-gui .jp-playback-rate-bar { 
 
    background-color: #a1c1f4; 
 
    cursor: pointer; 
 
    width: 60px; 
 
    min-width: 30px; 
 
} 
 
.jp-sleek .jp-gui .jp-playback-rate-bar .jp-playback-rate-bar-value { 
 
    background-color: #71a6fc; 
 
    height: 100%; 
 
    width: 14%; 
 
} 
 
.jp-sleek .jp-gui .jp-icon-controls button { 
 
    min-width: 42px; 
 
} 
 
.jp-sleek .jp-gui .jp-icon-controls .jp-progress { 
 
    background-color: #a1c1f4; 
 
    width: calc(100% - 42px - 60px - 42px - 42px - 100px); 
 
    min-width: 180px; 
 
    font-size: 20px; 
 
    position: relative; 
 
} 
 
.jp-sleek .jp-gui .jp-title-container { 
 
    width: 100px; 
 
    font-size: 12px; 
 
    vertical-align: top; 
 
} 
 
.jp-audio.jp-sleek .jp-gui .jp-title-container .jp-poster { 
 
    max-height: 100%; 
 
} 
 
img { 
 
    vertical-align: middle; 
 
} 
 
.jp-sleek .jp-gui .jp-title-container .jp-title { 
 
    font-weight: bold; 
 
    max-width: 135px; 
 
    text-overflow: ellipsis; 
 
    overflow: hidden; 
 
    display: inline-block; 
 
    vertical-align: middle; 
 
    margin-left: 10px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> 
 
<div class="jp-sleek jp-jplayer jp-audio jp-state-volume-low"> 
 
    <div class="jp-gui" style="opacity: 1;"> 
 
    <div class="jp-controls jp-icon-controls"> 
 
     <button class="jp-play"><i class="fa fa-play"></i> 
 
     </button> 
 
     <div class="jp-playback-rate-bar"> 
 
     <div class="jp-playback-rate-bar-value" style="width: 14.2857%;"></div> 
 
     </div> 
 
     <button class="jp-repeat"><i class="fa fa-repeat"></i> 
 
     </button> 
 
     <div class="jp-progress"> 
 
     </div> 
 
     <button class="jp-full-screen"><i class="fa fa-expand"></i> 
 
     </button> 
 
     <div class="jp-title-container"> 
 
     <img class="jp-poster" src="https://i.ytimg.com/vi/bM7SZ5SBzyY/hqdefault.jpg"> 
 
     <div class="jp-title">Fade</div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

+0

私はドンそのようなハードコード値を本当にしたいのですが、xが可能なのでnpmパッケージの一部としてCSSを提供しているので、他のコントロールの数が0または10のコントロールで同じになるはずです –

0

この

<div class="jp-sleek jp-jplayer jp-audio jp-state-volume-low"> 
    <div class="jp-gui" style="opacity: 1;"> 
    <div class="jp-controls jp-icon-controls"> 
    <div class="left"> 
     <button class="jp-play"><i class="fa fa-play"></i></button> 
     <div class="jp-playback-rate-bar"> 
     <div class="jp-playback-rate-bar-value" style="width: 14.2857%;"></div> 
     </div> 
     <button class="jp-repeat"><i class="fa fa-repeat"></i></button> 
     </div> 
     <div class="right"> 
     <button class="jp-full-screen"><i class="fa fa-expand"></i></button> 
     <div class="jp-title-container"><img class="jp-poster" src="https://i.ytimg.com/vi/bM7SZ5SBzyY/hqdefault.jpg"> 
     <div class="jp-title">Fade</div> 
     </div> 
     </div> 
     <div class="jp-progress"> 
     <div></div> 
     </div> 
    </div> 
    </div> 
</div> 


.right { 
    float: right; 
    height: 100%; 
} 
.left { 
    float: left; 
    height: 100%; 
} 
.jp-sleek { 
    z-index: 100; 
    width: 100%; 
    font-family: "Source Sans Pro", sans-serif; 
} 

.jp-sleek .jp-gui { 
    height: 42px; 
    background-color: #e5e5e5; 
    position: relative; 
} 

.fa { 
    font-size: 24px; 
} 

.jp-sleek .jp-gui .jp-controls { 
    height: 100%; 
    position: relative; 
    font-size: 24px; 
    white-space: nowrap; 
} 

.jp-sleek .jp-gui .jp-controls button { 
    color: #000; 
    padding: 0; 
    border: none; 
    background-color: transparent; 
} 

.jp-sleek .jp-gui .jp-controls .left > *, .jp-sleek .jp-gui .jp-controls .right > * { 
    margin-left: 5px; 
    margin-right: 5px; 
    display: inline-block; 
    height: 100%; 
    vertical-align: top; 
} 

.jp-sleek .jp-gui .jp-playback-rate-bar { 
    background-color: #a1c1f4; 
    cursor: pointer; 
    width: 60px; 
    min-width: 30px; 
} 

.jp-sleek .jp-gui .jp-playback-rate-bar .jp-playback-rate-bar-value { 
    background-color: #71a6fc; 
    height: 100%; 
    width: 14%; 
} 

.jp-sleek .jp-gui .jp-icon-controls button { 
    min-width: 42px; 
} 

.jp-sleek .jp-gui .jp-icon-controls .jp-progress { 
    padding-left: 200px; 
    padding-right: 170px; 
    height: 100%; 
} 

.jp-sleek .jp-gui .jp-icon-controls .jp-progress div { 
    background-color: #a1c1f4; 
    width: 100%; 
    height: 100%; 
    font-size: 20px; 
    position: relative; 
} 

.jp-sleek .jp-gui .jp-title-container { 
    font-size: 12px; 
    vertical-align: top; 
} 

.jp-audio.jp-sleek .jp-gui .jp-title-container .jp-poster { 
    max-height: 100%; 
} 

img { 
    vertical-align: middle; 
} 

.jp-sleek .jp-gui .jp-title-container .jp-title { 
    font-weight: bold; 
    max-width: 135px; 
    text-overflow: ellipsis; 
    overflow: hidden; 
    display: inline-block; 
    vertical-align: middle; 
    margin-left: 10px; 
} 

ライブデモを試してみてください - https://jsfiddle.net/grinmax_/3ej343z4/5/

関連する問題