如何重新排列CSS中内联块的顺序?

时间:2013-11-28 00:42:18

标签: html css

我目前在“成员操作”类下的内联块中有一排按钮彼此相邻。我想重新排列这些按钮的顺序。另外我想在这些左侧添加一个小图标。有关如何实现这一目标的任何想法?这是代码:

 .member_actions {
    padding: 0px 0px 0px 96px;

}

.member_actions .send_gift a{
    display: inline-block;
    border-style: solid;
    border-width: 1px 1px 1px 1px;
    border-color: #6c829b;
    line-height: 21px;
    height: 22px;
    padding: 0px 8px 0px 8px;
    margin: 0px 2px 0px 0px;
    background: image(btn_bg_red_big.png) repeat-x top left #c62800;
    color: #fff;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
}
.member_actions .block_profile a{
    position: absolute;
    float: left;
    border-style: solid;
    border-width: 1px 1px 1px 1px;
    border-color: #6c829b;
    line-height: 21px;
    height: 22px;
    padding: 0px 8px 0px 8px;
    margin: 0px 2px 0px 0px;
    background: image(btn_small_red.jpg) repeat-x top left #8ea3be;
    color: #fff;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
}

 .member_actions .send_message a{
    display: inline-block;
    border-style: solid;
    border-width: 1px 1px 1px 1px;
    border-color: #6c829b;
    line-height: 21px;
    height: 22px;
    padding: 0px 8px 0px 8px;
    margin: 0px 2px 0px 0px;
    background: image(btn_bg_red_big.png) repeat-x top left #c62800;
    color: #fff;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;

}

.member_actions .send_friend_request a, .member_actions .send_profile a, .member_actions .bookmark a {

    display: inline-block;
    border-style: solid;
    border-width: 1px 1px 1px 1px;
    border-color: #6c829b;
    line-height: 21px;
    height: 22px;
    padding: 0px 8px 0px 8px;
    margin: 0px 2px 0px 0px;
    background: image(btn_small_red.jpg) repeat-x top left #8ea3be;
    color: #fff;
    border-radius: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;

}

还有截图,以便您可以将其可视化。谢谢!Buttons!

1 个答案:

答案 0 :(得分:2)

如果您要重新排列.member_actions按钮,可以将position: absolute添加到班级,然后使用.member_actions:nth-child(1).member_actions:nth-child(2)等,然后添加left: -50px将元素定位在左侧50像素,或left: 50px定位元素向右50像素。请参阅示例jsfiddle

要添加小图标,请再次使用.member_actions:nth-child(n),其中n为1,2,3等以定位特定元素,添加background: url("path_to_img.png") 0 0 no-repeat; - >左起0像素,顶部0,并添加padding-left: 40px,假设40px是图像的宽度,如果不相应更改值。这将删除文本中留下的背景图像并向文本添加填充,因此它不会与图像重叠。