2017-11-03 87 views
2

我想在html/css中渲染一行已轉換的文本,但是我遇到了一些問題。當我縮放Y方向時,元素的整體對齊方式如圖所示。變換上的HTML文本對齊問題

enter image description here

試圖只需旋轉在相同的錯誤將L 180度的結果。如何在文本的y縮放軸上保持垂直對齊?比方說,我也用小型大寫字母做這個,對你的解決方案有任何改變?

這裏怎麼回事?

<style type="text/css" media="screen"> 
 
    #reflect{ 
 
    \t display: flex; 
 
    \t flex-basis: auto; 
 
    } 
 
    #reflectl { 
 
    \t /*transform: scaleX(-1) !important;*/ 
 
    \t transform: scale3d(-1,-1, 1); !important; 
 
    } 
 
    #reflecte { 
 
     \t transform: scaleX(-1) !important; 
 
    } 
 
    #reflectc { 
 
     \t transform: scaleX(-1) !important; 
 
    } 
 
</style> 
 

 
<text id=reflect> 
 
    <text id="reflectref">REF</text> 
 
    <text id="reflectl">L</text> 
 
    <text id="reflecte">E</text> 
 
    <text id="reflectc">C</text> 
 
    <text id="reflectt" >T</text> 
 
</text>

回答

0

這個問題似乎是,該元素是比它包含的文本較高,所以當你旋轉,旋轉中心是不完全的中間,所以當它這樣做的文字稍微偏離。最簡單的解決方案是將元素的高度設置爲其所需的高度。

<style type="text/css" media="screen"> 
 
    #reflect{ 
 
    \t display: flex; 
 
    \t flex-basis: auto; 
 
    } 
 
    #reflect text { 
 
     height: 17px; 
 
    } 
 
    #reflectl { 
 
    \t /*transform: scaleX(-1) !important;*/ 
 
    \t transform: scale3d(-1,-1, 1); !important; 
 
    } 
 
    #reflecte { 
 
     \t transform: scaleX(-1) !important; 
 
    } 
 
    #reflectc { 
 
     \t transform: scaleX(-1) !important; 
 
    } 
 
</style> 
 

 
<text id=reflect> 
 
    <text id="reflectref">REF</text> 
 
    <text id="reflectl">L</text> 
 
    <text id="reflecte">E</text> 
 
    <text id="reflectc">C</text> 
 
    <text id="reflectt" >T</text> 
 
</text>

<style type="text/css" media="screen"> 
 
    #reflect{ 
 
    \t display: flex; 
 
    \t flex-basis: auto; 
 
    } 
 
    #reflect text { 
 
     height: 17px; 
 
    } 
 
    #reflectl { 
 
    \t /*transform: scaleX(-1) !important;*/ 
 
    \t transform: scale3d(-1,-1, 1); !important; 
 
    } 
 
    #reflecte { 
 
     \t transform: scaleX(-1) !important; 
 
    } 
 
    #reflectc { 
 
     \t transform: scaleX(-1) !important; 
 
    } 
 
</style> 
 

 
<text id=reflect> 
 
    <text id="reflectref">ref</text> 
 
    <text id="reflectl">l</text> 
 
    <text id="reflecte">e</text> 
 
    <text id="reflectc">c</text> 
 
    <text id="reflectt" >t</text> 
 
</text>

+0

我想這對我最初寫這個問題上的瀏覽器,它似乎是功能性的。但是,在我的虛擬機(firefox 44)上運行較舊版本的firefox時,現在會使L太高,所以它似乎不能解決核心問題。這也會導致結果在小寫字母文本上顯着失敗。 – Skyler

+0

跟進更多。顯然這是受字體大小影響的。我已經以12的間隔得到正確的旋轉。 – Skyler