【问题标题】:Resize font in div width and height look like ctrl + t in photoshop调整 div 宽度和高度中的字体大小在 photoshop 中看起来像 ctrl + t
【发布时间】:2017-09-03 10:46:40
【问题描述】:

我可以在 div 中调整(可调整大小的 jquery ui)字体的大小,看起来像 Photoshop 中的 CTRL+T 吗?

我想用 jquery ui 调整 div 的大小并调整 div 中的自动字体大小 我没有反应意味着调整字体看起来像这张图片。

【问题讨论】:

    标签: jquery user-interface jquery-ui resizable


    【解决方案1】:

    我认为我刚刚编写的这段代码可能会对您有所帮助

    function createResizable(selector,relativeFontSize)
             {    
             	 $( selector ).css('font-size',parseInt(($(selector).width() * relativeFontSize)/100)+'px');     	
    	         $(function() {
    	            $( selector ).resizable({
    	               resize: function (event, ui) {
    	               	  var newFontSize = parseInt((ui.size.width * relativeFontSize)/100);
    	                  $(this).css('font-size',newFontSize+'px');
    	               }
    	            });
    	         });
    	         $(selector).resizable({ alsoResize: selector});
             }
    
             $(document).ready(function(){
             	createResizable('#resizable',45);
             });
             #resizable{ 
             	width: 150px; height: 75px; 
             	padding: 0.5em;text-align: center; margin: 0; 
             }
    <link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel = "stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <div id = "resizable" class = "ui-widget-content"> 
             Hello
          </div>

    【讨论】:

    • 你好,我的 tnx 为你的回答,但这不是回答我的问题,我说看起来像 Photoshop“拉伸”中的 CTRL + T
    • 对不起,这就是我所能提供的,你可以调整这段代码以获得你想要的
    猜你喜欢
    • 2017-12-08
    • 1970-01-01
    • 2011-07-10
    • 2013-04-28
    • 2014-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    相关资源
    最近更新 更多