English 中文(简体)
以 Jquery 无硬件编码曲线文字
原标题:Curving Text with Jquery no Hardcoding
  • 时间:2012-05-26 14:02:33
  •  标签:
  • jquery

我使用以下代码来更改文本框中任何类型文字的字体文本, 效果很好, 我现在想要做的是将文本显示为 CURVE 使用下面的 Jquery 。 我试图使用 < a href=" http:// tympanus. net/ codrops/2012/01/ 24/ arctext-js- curving- text- with- css3- and- jquery/" rel=" nofoln norefererr" > http://tympanus. net/ codrops/2012/01/ 24/ arctext-js- curving- text- with- cs3- and- jquery/ 。 但我看到, 大部分文本都是 harcoddddd 并且我不希望的。 所以, 如果在文本框中输入的文本应该显示为曲线而不是单行的话 。

""https://i.sstatic.net/TO2cZ.png" alt="此处输入图像描述"/"

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> - </title>

  <script type= text/javascript  src= https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js ></script>

  <link rel="stylesheet" type="text/css" href="/css/normalize.css">
  <link rel="stylesheet" type="text/css" href="/css/result-light.css">

  <style type= text/css >

  </style>



<script type= text/javascript >//<![CDATA[ 
$(window).load(function(){
            $( #ta ).keyup(function(){
                $( #float ).html("<p>"+$(this).val()+"</p>");
            });
            $("#fs").change(function() {
                $( #float ).css("font-family", $(this).val());
            });
            $("#size").change(function() {
                $( #float ).css("font-size", $(this).val() + "px");
            });

});//]]>  

</script>


</head>
<body>
  <form id="myform">
    <button>erase</button>
    <select id="fs"> 
        <option value="Arial">Arial</option>
        <option value="Verdana ">Verdana </option>
        <option value="Impact">Impact </option>
        <option value="Comic Sans MS">Comic Sans MS</option>
    </select>

    <select id="size">
        <option value="7">7</option>
        <option value="10">10</option>
        <option value="20">20</option>
        <option value="30">30</option>
    </select>
</form>    <textarea id=ta class="changeMe">Text into textarea</textarea>
    <div id="container" class="changeMe">
        <div id="float">
            <p>
                Text into container
            </p>
        </div>
    </div>


</body>


</html>
最佳回答

在您的代码中包含插件插件并将其用于脚本

$(window).load(function(){
    function update(){
        var text =  <p>  + $( #ta ).val() +  </p> ,
            size = $( #size ).val(),
            font = $( #fs ).val();

        $( #float )
            .css({
                fontFamily: font,
                fontSize: size +  px 
            })
            .html(text)
            .find( p )
            .arctext();

    }

    $( #ta ).keyup( update );
    $("#fs, #size").change( update );
});

Demo http://jsfiddle.net/gaby/AnyNQ/1/

问题回答

查看 < a href=> "http://circletype.labwire.ca" rel="nofollow" >CircleType.js 。 您可以看到它是如何在 < a href=>上使用的 http://petposter.co/poster.php? style=snakeoil" rel="nofollow" >这个网站 来创建曲线文本输入 。

完整披露:CircleType.js是我的项目,





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签