右对齐的垂直对齐按钮 [英] Vertically align button on pull-right

查看:54
本文介绍了右对齐的垂直对齐按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一些项目的列表,每个项目都有一个按钮,我正尝试使用 pull-right 进行右对齐.

I have a list with some items, and every item has a button that I'm trying to right-align using pull-right.

JSFiddle: https://jsfiddle.net/p3rd4rkq/

JSFiddle: https://jsfiddle.net/p3rd4rkq/

如您所见,按钮未正确垂直对齐.我试过设置 line-height:30px; ,虽然它确实正确地垂直对齐了按钮,但它也会更改整个列表项行的高度.JSFiddle: https://jsfiddle.net/2vr1o9qn/1/

As you can see, the button is not correctly aligned vertically. I've tried setting line-height: 30px;, and while this does vertically align the button correctly it also changes the height of the whole list item row. JSFiddle: https://jsfiddle.net/2vr1o9qn/1/

有没有更好的方法来对齐按钮并使高度保持相同大小?

Is there a better way to align the button and keep the height the same size?

推荐答案

然后尝试使用 margin-top:-5px; 这样的

.pull-right {

    margin-top: -5px; //added this
    float: right!important;
}

此处演示

这篇关于右对齐的垂直对齐按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆