2012-07-26 40 views
0

在Chrome和Firefox(或IE9,Opera)中打開此fiddle並查看差異。圍繞span-chrome問題換行文字

或看圖片:

enter image description here

能否鉻的行爲,例如Firefox?

+1

爲什麼你想要做這樣的事? – 2012-07-26 09:30:21

+1

@Stano我知道這是一個例子,但使用跨度在這裏是一個錯誤的做法,可能是他必須試圖得到這個,但在一個錯誤的方式 – 2012-07-26 09:39:44

+0

@Stano可以更好地使用div的 – 2012-07-26 09:47:41

回答

1

我相信不,它不能。您最好的選擇是在Chrome瀏覽器上以您希望的方式編寫此文檔,並在您檢測到用戶使用Chrome或其他瀏覽器時使用該版本。有關更多詳細信息,請參見this

OR

您可以使用的代碼看起來相同或相似的所有當前的瀏覽器。對於您的示例,您需要添加:

<span style="float:left">Test </span> 

到您的文本。

另一種解決方案是這樣的:

<html> 
<head> 
    <style type="text/css"> 
     #test{ 
      position: relative; 
      left: 120px; 
     } 
    </style> 

</head> 
<body style="margin:0px; padding: 0px;"> 

<span style="width: 100px; background:red; float: left; clear: left; height: 4px;" ></span> 
<span style="width: 220px; background:red; float: left; clear: left; height: 4px;" ></span> 

<div id = "test"> 
<span>Test </span> 
</div> 

</body> 
</html>​​​ 
+0

float left並非解決方案,當我有更多文本時 - 整個文本出現故障 – galer88 2012-07-26 10:44:17

+0

沒有辦法(您可以實現)那個chrome將會像firefox一樣行事。這對任何人都很明顯。你需要更清楚詳細地解釋你的問題,任何人都需要幫助。你想要文本做什麼? – 2012-07-26 11:43:09

1

只要給風格 '浮動:左' 到div

<html> 
<head> 

</head> 
<body style="margin:0px; padding: 0px;"> 

<span style="width: 100px; background:red; float: left; clear: left; height: 4px;" ></span> 
<span style="width: 220px; background:red; float: left; clear: left; height: 4px;" ></span> 

<div style="float:left"> 
<span>Test </span> 
</div> 

</body> 
</html>