我使用Jcrop這裏是我的模式:當用戶上傳一個大的圖像和畫面擴展模式或移動變得比模大如何限制模態圖像預覽的大小?
<!-- START modal-->
<div id="camera" tabindex="-1" role="dialog" aria-labelledby="cameraLabel" aria-hidden="true" class="modal fade">
<div class="modal-dialog">
<div class="modal-content" style="margin-left: 10px; margin-top: 10px;">
<div class="modal-header">
<button type="button" data-dismiss="modal" aria-hidden="true" class="close">x</button>
<h4 id="cameraLabel" class="modal-title">Upload a photo of yourself</h4>
</div>
<div class="modal-body">
<form action="/overview/setprofileimage" method="POST" enctype="multipart/form-data" id="coords">
<div class ="form-group">
<span id="err_coords" style="color: #ff0000; float: left; text-align: center; width: 100%;"></span>
</div><br>
<input type='file' id="imgAvatar" name="image" onchange="readURLAvatar(this, 'avatar');" />
<img id="avatar" src="#" alt="your image" style="margin-top:10px; margin-bottom:10px; max-height: 100vh; max-width: 100vh;" />
<div class="inline-labels">
<input type="hidden" id="x" name="crop[x]" />
<input type="hidden" id="y" name="crop[y]" />
<input type="hidden" id="w" name="crop[w]" />
<input type="hidden" id="h" name="crop[h]" />
</div>
<br>
<input type="hidden" size="4" id="uplloadAvatar" name="uplloadAvatar" value=""/>
<button type="button" class="btn btn-danger btn-sm" onclick="checkCoordsImg(1);">Crop & Upload</button>
<button type="button" class="btn btn-success btn-sm" onclick="checkCoordsImg(2);">Upload</button>
</form>
<br>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">Close</button>
</div>
</div>
</div>
</div>
<!-- END modal-->
我的問題就來了。我試圖限制模態對話框的寬度,但它不適合響應式設計。
我做根據您的回答一些小的調整,它完美的作品。我想關鍵在於使用媒體查詢不同大小的屏幕。非常感謝! – Blkc
是的,媒體查詢是你的朋友處理不同的屏幕尺寸,你是最受歡迎的 – Shehary