Umeditor width adaptive

Source: Internet
Author: User

Baidu editor umeditor. After a rich text editing box is generated, a horizontal scroll bar will appear when the window size is changed, even if you call the interface to set the editor width to 100%. For example:

var um = UM.getEditor(‘<%=txtContent.ClientID%>‘);            um.setWidth("100%");

This is because umeditor internally generates a CSS class "edui-body-container" Div to present the user input area, and the width of this div is the absolute value of the width of the obtained target element. This explains that if the width of the target element is small, even if the width of umeditor is set to 100%, the Editable area will be relatively small.

So the question is, which excavator is the best in China? :)

We can solve this problem in two ways:

1. Modify the source code, find the location where edui-body-iner is generated, and modify it;

Second, you can directly set the edui-body-container width after initializing umeditor.

I am a lazy, and I still need to find the specific location to modify the source code. After the modification, I need to test the content. If it is a compressed mini package, it will be more troublesome. Therefore, I chose the latter method. I only need to add one sentence:

            var um = UM.getEditor(‘<%=txtContent.ClientID%>‘);            um.setWidth("100%");            $(".edui-body-container").css("width", "98%");

Because it is a class selector, if there are multiple umeditors in a page, write it after initializing all the editors.

$(".edui-body-container").css("width", "98%");

You can.

Umeditor width adaptive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.