简体   繁体   English

如何限制使用框提交的图像大小

[英]how to limit the size of image that gets submitted with a box

Hello I'm using ckeditor to let users to post image but the thing is, the size of an image that user post can be too big. 您好,我使用ckeditor允许用户发布图像,但事实是,用户发布的图像大小可能太大。 so I was wondering if I can use some css or javascript to hide the content(would be better to minimize the content but I don't have a clue how I can do that) if the content is too big that it goes out of the box. 所以我想知道我是否可以使用一些CSS或javascript来隐藏内容(最好是最小化内容,但我不知道如何做到这一点)如果内容太大而不能超出框。 I'm using bootstrap panel as a box 我正在使用自举面板作为一个盒子

<div class="panel-body">

{{ post.content|safe }}

    </div>

this post.content can't be too big that it goes out of panel-body, how should I prevent from it going out(hide the content)? 此post.content不能太大,以至于不能超出面板主体,我应该如何防止它退出(隐藏内容)?

Try to put a max-width on your images, like this : 尝试在图像上放置最大宽度,如下所示:

.panel-body img {
   max-width: 100%;
}

Use css .panel-body { overflow:hidden; } 使用CSS .panel-body { overflow:hidden; } .panel-body { overflow:hidden; } on your container to hide the overflowing content (your image). .panel-body { overflow:hidden; }您的容器来隐藏溢出的内容(图像)上。

A more elegant solution can be to automatically resize your images to not overflow the container width. 更好的解决方案是自动调整图像大小,以免容器宽度溢出。 You can achieve this with 您可以使用

.panel-body img {
    max-width:100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM