2010-04-30 77 views
1
<!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"> 
<head> 
<style type="text/css"> 
#action-icons 
{ 
    float:right; 
} 
#action-icons.img 
{ 
    position:relative; 
    top:-30px; 
    padding-right:200px; 
} 
</style> 
</head> 

<body> 
    <h1 class="edit">Some nifty title 
    <span id="action-icons"> 
    <img src="foo.png" width="64" height="64" alt="" id="newsticky"/> 
    <img src="bar.png" width="60" height="60" alt="" id="trash"/> 
    </span> 
    </h1> 
</body> 
</html> 

回答

2

尝试增加:

#action-icons.img 
{ 
    position:relative; 
    top:-30px; 
    padding-right:200px; 
} 

可以办得到。

编辑:你有#action-icons.img删除点,所以它的#action-icons img

的点设置img为一个类,使你拥有了它,产生的HTML代码如下所示:

​​

希望它能帮助。

编辑 - 以下是完整的工作代码:

<!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"> 
<head> 
<style type="text/css"> 
#action-icons 
{ 
    float:right; 
} 
#action-icons img 
{ 
    position:relative; 
    top:-30px; 
    margin-left:50px; 
} 
</style> 
</head> 

<body> 
    <h1 class="edit">Some nifty title 
    <span id="action-icons"> 
    <img src="foo.png" width="64" height="64" alt="" id="newsticky"/> 
    <img src="bar.png" width="60" height="60" alt="" id="trash"/> 
    </span> 
    </h1> 
</body> 
</html> 
+0

它不起作用。 – ripper234 2010-04-30 07:53:20

+0

谢谢,现在它:) – ripper234 2010-04-30 07:58:12

+0

嘿,事实证明,内联并不需要,问题只是我的选择。 – ripper234 2010-04-30 08:01:27

2

尝试margin-right

,并使用

#action-icons img 

解决图像。

#action-icons.img 

的意思是“与ID action-iconsimg的任何元件。

+0

它不起作用。 – ripper234 2010-04-30 07:52:09

+1

@ripper另外,使用'img#action-icons'而不是'#action-icons.img'。就目前而言,该规则并未得到应用。 – 2010-04-30 07:53:21

+0

我没有复制! :) – Kyle 2010-04-30 07:55:40

2

变化

#action-icons.img 

#action-icons img 

并检查

它适用于我在火狐上