我怎样才能创建一个名为“commenttweet2”的CSS类,它会在commenttweet
水平对齐的右边浮动15个像素?
PHP / HTML代码:
echo "<div class='commenttweet'>";
echo "<a href='$url'>Tweet this</a>";
echo "</div>";
CSS:
.commenttweet {
margin-left:0px;
margin-top:15px;
color: #004993;
font-family:Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
height: 15px;
padding-bottom: 0px;
padding-left: 5px;
padding-right: 5px;
padding-top: 2px;
}
答案 0 :(得分:0)
你必须把位置属性放在commenttweet类中:
commenttweet {
position:absolute;
margin-left:0px;
margin-top:15px;
color: #004993;
font-family:Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
height: 15px;
padding-bottom: 0px;
padding-left: 5px;
padding-right: 5px;
padding-top: 2px;
}
为commenttweet2 div创建以下类:
.commenttweet2 {
position: absolute;
margin:15px 0 0 15px;
}
答案 1 :(得分:0)
不确定您拥有的其他代码,但真正简单的启动会让您入门。示例显示@ http://jsfiddle.net/robx/FSyph/
HTML:
<div class='commenttweet'>
<a href='http://'>Tweet this</a>
</div>
<div class='commenttweet'>
<a href='http://'>Tweet this 2</a>
</div>
CSS:
.commenttweet{
float:left;
margin:10px;
padding:8px;
border:1px solid #000;
}