Twitter bootstrap 3 设置引导标记输入中标记的最大宽度

Twitter bootstrap 3 设置引导标记输入中标记的最大宽度,twitter-bootstrap-3,bootstrap-tags-input,Twitter Bootstrap 3,Bootstrap Tags Input,Bootstrap Tags Input中的标记溢出容器 因此,我想设置标签的最大宽度,或者是否有任何方法可以阻止标签在引导标签输入中溢出 如需参考,请访问。只需添加引导标记输入事件: $('#Id').on('itemAdded', function(obj) { var tagsinputWidth = $('#Id').parent().find('.bootstrap-tagsinput').width();// Width of Bootstrap Tags Input.

Bootstrap Tags Input
中的标记溢出容器

因此,我想设置标签的最大宽度,或者是否有任何方法可以阻止标签在
引导标签输入中溢出


如需参考,请访问。

只需添加引导标记输入事件:

$('#Id').on('itemAdded', function(obj) {

    var tagsinputWidth = $('#Id').parent().find('.bootstrap-tagsinput').width();// Width of Bootstrap Tags Input.
    var tagWidth = $('#Id').parent().find('.bootstrap-tagsinput span.tag').last().width();// To get the Width of individual Tag.
    if(tagWidth > tagsinputWidth) {
        //If Width of the Tag is more than the width of Container then we crop text of the Tag
        var tagsText = obj.item.value;// To Get Tags Value
        var res = tagsText.substr(0, 5); // Here I'm displaying only first 5 Characters.(You can give any number)  
        $('#Id').parent().find('.bootstrap-tagsinput span.tag').last().html(res+"..." +'<span data-role="remove"></span>');
    }
});
$('#Id')。在('itemsadded',函数(obj)上{
var tagsinputWidth=$('#Id').parent().find('.bootstrap tagsinput').width();//引导标记输入的宽度。
var tagWidth=$('#Id').parent().find('.bootstrap tagsinput span.tag').last().width();//获取单个标记的宽度。
如果(标记宽度>标记输入宽度){
//如果标签的宽度大于容器的宽度,则裁剪标签的文本
var tagsText=obj.item.value;//获取标记值
var res=tagsText.substr(0,5);//这里我只显示前5个字符。(您可以给出任何数字)
$('#Id').parent().find('.bootstrap tagsinput span.tag').last().html(res+“…”+”);
}
});
但问题是,用户看不到他/她添加的标签的全部文本。因此,我们可以为标签放置“标题”

我们需要在第127行的bootstrap-tagsinput.js中进行自定义

var $tag = $('<span class="tag ' + htmlEncode(tagClass) + '" title="'+htmlEncode(itemText)+'">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
var$tag=$(''+htmlEncode(itemText)+'');

因此,现在用户可以在鼠标移到特定标签上时看到文本。

发布问题的屏幕截图,以便我们可以更轻松地提供帮助。是的,但我没有足够的排序来发布屏幕截图。一个小的、可复制的示例可能会有所帮助,可能是在or中。或者至少包括相关的CSS/HTML.Fine Onteru,它很好用。但我希望这是一个方便的解决方案。我仍然在等待最佳解决方案。不管怎样,现在我都同意你的解决方案。非常感谢你。坚持下去。