在A H2标签内对齐div

时间:2014-01-30 10:50:02

标签: html css

我有一个问题,我需要在H2标签内插入一个div。

这可能吗?我认为应该。 只想到我不知道如何完成它。我试过以下

HTML

<h2 id="strap">Blah Blah & Some More Blah Blah Blah    
    <div class="section contain">            
        <a href="http://www.facebook.com/BlahBlah" rel="nofollow" target="_blank"><img alt="facebook" src="<%=SkinPath %>img/social/fb.png"/></a>
        <a href="http://twitter.com/BlahBlah" rel="nofollow" target="_blank"><img alt="twitter" src="<%=SkinPath %>img/social/tw.png"/></a>
        <a href="http://BlahBlah.wordpress.com/" rel="nofollow" target="_blank"><img alt="blog" src="<%=SkinPath %>img/social/wp.png"/></a>          
    </div>
</h2>

JSFIDDLE

我希望div元素(社交图标)出现在同一行。还有其他方法吗?

3 个答案:

答案 0 :(得分:5)

您无法在h2内使用h2。如果您将内部h2更改为span,则它将是内联的。

像这样:http://jsfiddle.net/nNuwT/2/

答案 1 :(得分:1)

演示FIDDLE

<强> CSS

.contain
{
    display:inline;
}

答案 2 :(得分:0)

这就是我想要的,

Forked Fiddle

希望这对你有用....

#strap{
float:left;
line-height: 100%;
display:block;
width: 100%;
background: #dddddd;
 padding: 10px;
}
.section {
float:right;
display: inline-block;
}
.section span {
font-size: 18px;
margin-right: 5px;
display:block;
float: left;
}
.section img {
width: 40px;
height: 40px;
}
相关问题