1

私は使っている

$('.profile-block .first-name').text(profile_user.first_name)

テキストを設定するには

<h2 class="name">
    <span class="first-name"></span>
    <span class="last-name"></span>
</h2>

しかし、テキストはレンダリングされていません

私は iOS 7.0 とその Safari アプリを使用しています。

Web インスペクタを開いて、フォント サイズを変更するなどして要素を強制的に再レン​​ダリングし、CSS の編集を開始すると、テキストが表示されます。

ノードに入れるソリューションを思いつきました

<span class="first-name">&nbsp;</span>

その後、テキストがレンダリングされます....

なぜこうなった?

4

1 に答える 1

-1

So you can do something quite nasty (I've not found a better way), to force a browser re-flow:

var forceReflow = function(el) {
    el = el || document.body;
    el.style.position = 'static';
    setTimeout(function() {
        el.style.position = 'relative';
    }, 0);
}

This should fix your issue. Though it's not the best performant to do it on the body, so maybe pass in the parent of .profile-block

于 2013-10-31T15:51:05.393 に答える