问题描述
我有一个包含一些项目的列表,每个项目都有一个按钮,我正尝试使用 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;
}
这篇关于右对齐的垂直对齐按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!