在 Chrome 和 Firefox(或 IE9、Opera)中打开这个小提琴并查看差异。
或见图片:
chrome可以像firefox一样表现吗?
只需将样式 'float:left' 赋予 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>
我相信不,它不能。最好的办法是在 Chrome 上以您想要的方式编写此代码,并在检测到用户使用的是 Chrome 还是其他浏览器时使用该版本。有关更多详细信息,请参阅此内容。
或者
您可以使用在所有当前浏览器中看起来相同或相似的代码。对于您的示例,您需要添加:
<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>