【问题标题】:Resize asp:Label at runtime [closed]调整asp:运行时的标签[关闭]
【发布时间】:2014-06-04 07:38:56
【问题描述】:

我试图让客户端在运行时重新调整标签的文本大小。

jQuery Resizable 不起作用,它只适用于文本框/下拉列表等,但对于标签它不起作用。

有什么建议吗?

【问题讨论】:

标签: jquery asp.net


【解决方案1】:

使用 resizable() 的 resize() 事件

例子

<style>
.lbl {display:block}
</style>

...
<asp:Label ID="Label1" ClientIDMode="Static" runat="server" 
    Text="Label" CssClass="lbl"></asp:Label>

...
<script>
    $(function() {
        $( "#label" ).resizable({
           resize: function( event, ui ) {
               var height = ui.element.height(); 
               ui.element.css({'font-size':height+'%'});
           }
        });
    });
</script>

演示:http://jsbin.com/cotiribo/2/edit?html,output

【讨论】:

  • 这只会重新调整块的大小,不会影响标签的文本大小,我希望能够重新调整标签的文本大小。
  • 查看更新的代码和新的演示
  • 没有显示块有什么办法吗?相同的主体,但仅在标签上
  • 不,resizable() 不适用于没有显示块的跨度。如果需要,您可以使用 div 代替 span(但在这种情况下,您需要执行类似
    或类似的操作)
猜你喜欢
  • 2016-02-03
  • 2014-04-07
  • 2013-02-12
  • 1970-01-01
  • 2011-11-05
  • 1970-01-01
  • 2017-01-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多