我想創建一個使用JqueryUI的程序棒注意類。我用這種不同的字體創建了筆記。Html風格:字體家族變得搞砸了,而渲染
<div class="object ui-draggable ui-draggable-handle ui-resizable selected" id="element_9" style="top: 320.919px; left: 1145.88px; color: rgb(185, 54, 68); font-size: 1008.51%; width: 571px; right: auto; height: 606px; bottom: auto; transform: none; font-weight: 400; font-family: "Allerta Stencil", sans-serif;"
data-type="text" data-font="f65">
<div class="text-editable" contenteditable="false" style="cursor: all-scroll;">Enter your text here </div>
<div class="ui-rotatable-handle ui-draggable" style="transform: scale(2.22222);"></div>
<div class="ui-resizable-handle ui-resizable-ne" style="z-index: 90; transform: scale(2.22222);"></div>
<div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90; transform: scale(2.22222);"></div>
<div class="ui-resizable-handle ui-resizable-sw" style="z-index: 90; transform: scale(2.22222);"></div>
<div class="ui-resizable-handle ui-resizable-nw" style="z-index: 90; transform: scale(2.22222);"></div>
</div>
現在,我使用PHP作爲一個HTML文件保存它們。並試圖加載HTML文件,這是我在瀏覽器呈現HTML文件後收到的。
<div class="object ui-draggable ui-draggable-handle ui-resizable selected" id="element_8" style="top: 320.919px; left: 1145.88px; color: rgb(185, 54, 68); font-size: 1008.51%; width: 571px; right: auto; height: 606px; bottom: auto; transform: none; font-weight: 400; z-index: auto;"
allerta="" stencil ",=" " sans-serif;"="" data-type="text" data-font="f65">
<div class="text-editable" contenteditable="false" style="cursor: all-scroll;">Enter your text here </div>
<div class="ui-rotatable-handle ui-draggable" style="transform: scale(5.71429);"></div>
<div class="ui-resizable-handle ui-resizable-ne" style="z-index: 90; transform: scale(5.71429);"></div>
<div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90; transform: scale(5.71429);"></div>
<div class="ui-resizable-handle ui-resizable-sw" style="z-index: 90; transform: scale(5.71429);"></div>
<div class="ui-resizable-handle ui-resizable-nw" style="z-index: 90; transform: scale(5.71429);"></div>
</div>
正如你所看到的樣式父標籤的並不一致。我從Chrome Inspector複製粘貼了上述outerHTML。我可以看到瀏覽器會自動插入一個「」字型家庭,當我做到這一點
object.css({"font-family": this.font_family});
和this.font家庭是從JSON看起來像這樣
var fonts = [{font_family : 'Allerta Stencil, sans-serif', name: 'f65', val: "Allerta Stencil"},...]
那麼爲什麼間它重新加載文件時,樣式不能正確回讀?有沒有一種方法可以解決這個問題。我已經閱讀了一些與此類似的SO問題,其中帶有空格的字體名稱需要引號。我的問題是,如果引號包含在瀏覽器中,那麼爲什麼當重新加載HTML文件引號時會被忽略?
其實我提到的jquery在做$(object).css('font-family','...')時插入了引號。 – Sammy
我自己也做了相同的修改。但這是Chrome應用更改後提供的內容 style =「top:749.575px; left:1651.03px; color:rgb(185,54,68); width:571px; right:auto; height:154px; bottom: auto; transform:none; font-weight:400; font-size:1008.51%; font-family:「Allerta Stencil」,sans-serif;「 PHP保存爲 style =「top:812.433px; left:542.454px; color:rgb(185,54,68); right:auto; bottom:auto; transform:none; font-size:1680。8%;身高:自動;寬度:751.857px; font-weight:400; font-family:" Allerta Stencil ",sans-serif;「 – Sammy
但是,當它加載回來時,它弄亂了HTML – Sammy