私は、モバイルとデスクトップのブートストラップモーダルに関して厄介な問題があります。モバイル向けのブートストラップモードのみを表示します。デスクトップ用ではありません。
ので、質問が短くなります。
私はおよび唯一のモバイル/タブレットのために有効にすることができますどのように?
私は、モバイルとデスクトップのブートストラップモーダルに関して厄介な問題があります。モバイル向けのブートストラップモードのみを表示します。デスクトップ用ではありません。
ので、質問が短くなります。
私はおよび唯一のモバイル/タブレットのために有効にすることができますどのように?
あなたはresponsive utilitiesクラスを使用することができます。あなたのケースでは、あなたがモバイル上にあるかどうかを確認するには、いくつかの方法があります
<div class="modal fade hidden-lg hidden-md" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
モーダルボックスに.hidden-md
または.hidden-md
クラスを使用する必要があります。あなたはread more hereです。
は、この例では、私はちょうど画面のwidth
を使用し、それに基づいてモーダルを表示するかしない場合を決めた:ここ
$('#myModal').on('show.bs.modal', function (e) {
if (window.innerWidth < 800) {
return e.preventDefault();
}
})
はあなたのjsfiddleの更新です:
http://jsfiddle.net/1aeur58f/28/
これは実際には選択肢ではありません。なぜなら、デスクトップブラウザのサイズを変更すると、モーダルを得ることができるからです。 – RulerNature
この具体的な例では、幅を使用しています。また、私たちがモバイルであるかどうかを確認する方法の他のオプションへのリンクを(JavaScriptを使用して)与えました。それらのうちのどれかを使用することができます:) – Dekel
btw、ブートストラップによる 'md/lg'クラスは同じように動作します。それらは幅ベースであり、実際のモバイルベースではありません。 – Dekel
UHTMLで.hidden-lgクラスを使用できます。下のコードをチェックすると、大きなデバイスでdivを非表示にします。 参照 - Bootstrap Responsive Utilities
<div class="panel panel-warning hidden-lg" id="mymodal" data-toggle="modal" data-target="#myModal">
<div class="panel-body">
<h3>click on panel to open the modal</h3>
</div>
</div>
<!-- Modal -->
<div class="modal fade hidden-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
は幅に基づいていますので、デスクトップ上でブラウザのサイズを変更する場合はオプションではありません。 – RulerNature
この質問を確認してください。 http://stackoverflow.com/questions/23841543/hiding-div-if-using-mobile-browser – acmsohail
は、あなたが特定のモーダルまたはそれらのすべてを無効にしますか?モーダルがある場合(例えば、リンク/ボタンをクリックするとデスクトップ上でどうなるでしょうか?) – Dekel
@Dekel固有のモーダル:)デスクトップ上では、リダイレクトする必要のあるリンクやモーダルは必要ありませんが、モバイルではモーダルを開きたいと考えています。 – RulerNature