0

私は、ある英国の政治家についてのパロディ ページを作成しており、Javascript を使用して彼の政策を自動的に生成しています。

私のサイトでは、テキストを生成する Javascript が正常に機能しています。ただし、Javascript の出力を test.html ページの「吹き出し」内に適切に表示することはあまりできていません (URL を投稿するのがルールに反する場合は申し訳ありません。私は実際のページに人々を向けることによって言っています)。

ここでいくつかの質問:

1) iframe を使用して、ポリシーを吹き出しに入れようとしています。まず、画像に対して常に正しい位置に配置されるように div を作成する方法がわかりません。必要な CSS コードの手がかりはありますか? それとも、相対位置を完全に放棄して絶対値を使用する方がよいでしょうか?

2) さらに重要なことは、ポリシーのテキストをバルーン内で折り返すにはどうすればよいですか? バルーンのボックス内で単語をラップするだけで済みます。バルーンの輪郭をたどるなどの派手なことは必要ありません。

3) フォント、サイズなどのテキスト属性を指定するにはどうすればよいですか?

同様の質問を検索しましたが、特定のプロジェクトに直接適用できるものは見つかりませんでした。

ご協力ありがとうございます。ここは驚くほど便利なサイトのようです。

更新:わかりました、私は明らかにここで私の深さから外れているので、可能であればこれを達成するためのより簡単な方法についてのアドバイスをいただければ幸いです。

テキスト ジェネレーターのコードは、policies.html リンクのソース コードを表示することで確認できます。

私がやろうとしているのは、この生成されたテキストを test.html ページに表示することです。しかし、フォーマットなしでプレーンテキストで表示することしかできず、テキストボックス内で折り返されていません。

4

2 に答える 2

0

jQuery を使用すると、テキストが収まるように画像を分割する必要がある場合があります。

<script type="text/javascript">
    function getRandomText()
    {
        var verbs=['Butcher','Punish','Impoverish','Annihilate','Dispossess','Humiliate','Denounce','Vilify','Torture','Execute','Shaft'];
        var victims=['single mothers','young people','the disabled','benefit scroungers','council tenants','council estate riff-raff','human rights lawyers','do-gooders','judges who say I am wrong','the poor'];
        var outcomes=['until they vote Tory','with a spoon','with a cattle prod','with a Taser','with a spoon','during a zombie apocalypse'];
        var endings=[' and then cut their benefits.',', then let Dementors suck out their lifeforce.',', then give bankers another bailout.',' and then make them work for nothing.','. I will pass emergency regulations to make it legal.',' and send their relatives to the workhouse.',', then let them eat cake.'];

        for(x=0;x<Math.round(Math.random()*10);x++){
            var _JuNk=Math.random();
        }

        return verbs[Math.round(Math.random()*(verbs.length-1))]+' '+victims[Math.round(Math.random()*(victims.length-1))]+' '+outcomes[Math.round(Math.random()*(outcomes.length-1))]+endings[Math.round(Math.random()*(endings.length-1))]+'\n';
    }

    $(document).ready(function() {
        $("#Refresh").click(function () {
            var randomText = getRandomText();
            $("#Result").html(randomText);
        })
    });
    </script>
</head>

<body>
    <div class="container">
        <div class="content">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
                non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
            </p>
            <button id="Refresh">More...</button>
            <div class="picture">
                <table class="table">
                    <tr>
                        <td>Top Left</td>
                        <td>Top Center</td>
                        <td>Rop RIght</td>
                    </tr>
                    <tr>
                        <td>Middle Left</td>
                        <td><div id="Result">Balloon Content</div></td>
                        <td>Middle Right</td>
                    </tr>
                    <tr>
                        <td>Bottom Left</td>
                        <td>Bottom Center</td>
                        <td>Bottom Right</td>
                    </tr>
                </table>
            </div>
    </div>
    <!-- end .content -->
    </div>
    <!-- end .container -->
    </div>
</body>
于 2013-02-24T06:03:43.980 に答える
0

これはあなたの特定の質問には関係ないかもしれませんが、HTML ドキュメントで PHP を使用したい場合に行うことです。まず、PHPスクリプト(あなたの場合はJavascript)を用意します次に、HTMLドキュメント内で次のようなものを使用します

    <!--#include virtual="../quote.js" -->
于 2013-02-24T06:12:31.070 に答える