2011-05-20 24 views
0

一直在優化一些使用精靈的東西,並遇到了這個問題......我需要兩個塊對齊到文本的右側,但不管我做了什麼,他們開始左對齊在它下面的新行。使用position:absolute似乎可以在我的編輯器中工作,但是在發佈時不會。需要將兩個塊對齊在文本的右側 - 可能嗎?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head> 
<style type="text/css">  
a.facebook{margin:0 5px 0 0;float:left;display:block;width:30px;height:30px;background:url(social.png) no-repeat 0 0;background-position:0px -38px;overflow:hidden;text-indent:-10000px;font-size:0px;line-height:0px;} 
a.twitter{margin:0 5px 0 0;float:left;display:block;width:30px;height:30px;background:url(social.png) no-repeat 0 0;background-position:-30px -38px;overflow:hidden;text-indent:-10000px;font-size:0px;line-height:0px;} 
</style> 
</head> 

<body> 
<div>this is a test 
<a href="#" onclick="window.open('http://test.com')" title="Find us on Facebook!" class="facebook">Find us on Facebook!</a> 
<a href="#" onclick="window.open('http://test.com')" title="Find us on Twitter!" class="twitter">Find us on Twitter</a></div> 
</body> 
</html> 
+0

你可以發佈一個鏈接到你的網站上的現場演示(顯示相關圖片),或者[JS小提琴演示](http://jsfiddle.net/)? – 2011-05-20 22:23:52

回答

0

如果我有問題,我想你在尋找float:right,但相對浮動對浮動元素通知,遵循,所以你需要將文本之前的鏈接。

編輯:更多的數據 如果你想塊插入到其他元素,就好像它們是文本的一部分,你應該讓他們的display:inline-block(在IE6這僅適用於已行內默認元素)。但是,他們會出現在他們插入的位置,而不是浮動的。

+0

這有點有用,但我需要兩個塊與文本內聯...如果我使用浮點右邊,那麼它位於頁面的極右端,而不是在文本之後。 – user756659 2011-05-21 01:36:55

+0

基本上我正在尋找的是'這是一個測試',有兩個30x30的塊元素跟隨內聯到右邊,好像他們是句子的一部分。 – user756659 2011-05-21 01:44:41

+0

看看最新的編輯是你在找什麼。 – entonio 2011-05-24 00:55:03

相關問題