- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
https://github.com/fengyuanchen/cropper
我在我的项目上成功实现了裁剪器,但它在移动设备上不可用,因为图像总是比模态容器大(裁剪器位于模态内部),并且我无法在移动资源上看到所有图像,因为它溢出了
我尝试了容器上、img 标签上的最大宽度、宽度的几种组合,但无法做到这一点,我已经设置了:
最小容器宽度:568,最小容器高度:320
如果我删除它,它可以工作,但默认值为 100x200,即使在移动设备上也太小,而在 PC 上则非常小
这是我的设置:
reader.onloadend = function () {
$cropperModal.find('.image-container').html($img);
$img.attr('src', reader.result);
$img.cropper({
preview: '.image-preview',
aspectRatio: 16 / 11,
autoCropArea: 1,
movable: false,
cropBoxResizable: true,
minContainerWidth: 568,
minContainerHeight: 320
});
};
莫代尔:
var modalTemplate = '' +
'<div class="modal fade" tabindex="-1" role="dialog" style="z-index: 99999;">' +
'<div class="modal-dialog" role="document">' +
'<div class="modal-content-recorte widthimage">' +
'<div class="modal-header">' +
'<h4 class="popup_title"> @lang('popups.crop_img') </h4>' +
'<p class="popupcontent"> @lang('popups.crop_img_desc') </p>' +
'</div>' +
'<div class="modal-body">' +
'<div class="image-container""> </div>' +
'</div>' +
'<div class="modal-footer" style="text-align:center">' +
'<button type="button" class="btn btn-primary crop-upload">Upload</button>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'';
我想设置一个最大尺寸,并且当裁剪器的内容小于设置的最大宽度/高度时,它会适应屏幕。
谢谢
最佳答案
来自 GitHub:
The size of the cropper inherits from the size of the image's parent element (wrapper), so be sure to wrap the image with a visible block element.
因此,将您的cropper元素包装在div中:
<div class="img-container">
<img id="cropperImage">
</div>
然后在你的 CSS 中
.img-container{
min-width: 50vw; /*your responsive value here*/
min-height: 50vh; /*your responsive value here*/
}
#cropperImage{
max-width: 100%; /* prevent the overflow blip when the modal loads */
}
您可以使用 window.innerWidth
等设置 minContainerWidth
,但容器不会响应,因此如果用户旋转手机,它将溢出到超出范围莫代尔并且看起来很糟糕。
关于javascript - 使 fengyuanchen 裁剪器响应式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48481769/
我正在使用 crop tool from fengyuanchen ,它有很棒的功能。我正在尝试制作一个具有动态尺寸的固定裁剪框。 但我目前只是想弄清楚如何使它达到一定的大小。 我试过以下方法: $(
https://github.com/fengyuanchen/cropper 我在我的项目上成功实现了裁剪器,但它在移动设备上不可用,因为图像总是比模态容器大(裁剪器位于模态内部),并且我无法在移动
我正在尝试使用上一个/下一个箭头制作数据选择器。内联版本正在运行。但我想使用带有上个月/下个月数据 View 的按钮进行输入(就像内联版本一样)。 HTML Prev Next JS
我正在尝试使用 fengyuanchen jquerycropper 插件 - https://github.com/fengyuanchen/cropper 施加裁剪数据输出的最小大小 该插件提供了
在我的网络应用程序中,我试图实现个人资料图片上传,它允许您在上传图像后裁剪图像。为此,我使用此处的 jQuery 裁剪插件: http://fengyuanchen.github.io/cropper
使用这个日期选择器插件 https://github.com/fengyuanchen/datepicker我目前仅启用星期二,如何禁用特定日期?例如 10 月 31 日和 12 月 19 日? 我已
我浏览了 fengyuanchen 的 cropper 文档。如果旋转,我希望图像默认适合 Canvas 。但我找不到实现这一目标的方法。知道如何实现此功能吗? 我希望它成为默认值:link 在此处查
我正在使用Datepicker从输入字段中选择一个日期并将其返回到提交表单之前的值中。问题是,当使用 .getDate 时,它仅返回第一天。我需要将值输出为 yyyy-mm-dd。 任何帮助都会很棒!
如何使用我自己的按钮裁剪图像? 我试着执行这个 var canvas = $selector.cropper('getCroppedCanvas') 但它返回空值。 有没有办法得到裁剪后的 Canva
我正在使用 fengyuanchen(来自 github)的出色 Cropper,我被困在一个小细节上。任何使用过此组件的人都可以向我展示一两行简单的 javascript/jquery,这将使我能够
我在使用 fengyuanchen jQuery Cropper.js v3.0.0 时遇到了一个小问题。我正在尝试覆盖默认预览代码,使其与原始图像的显示尺寸相同。 我目前遇到的问题是,一旦图像的高度
我是一名优秀的程序员,十分优秀!