2012-07-26 35 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>