简体   繁体   中英

Background icon image and caption text are not aligned vertically

Plunker code is here .

I am trying to create a dropdown with an icon in the front. I am facing an issue where the vertical alignment for icon is good but for the caption, the text is displayed below the middle line as,

在此处输入图片说明

The caption Select One is below the middle line. How can i move it up, so that it is at same level as the icon?

Please update the following code in your css..

.grouped-list-btn-content > .grouped-list-text {
    margin-top: 6px;
}

There is a margin-top on the text of 9px:

.grouped-list-btn-content > .grouped-list-text {
    margin-left: 5px;
    margin-top: 9px;
}

change it to 5px:

.grouped-list-btn-content > .grouped-list-text {
    margin-left: 5px;
    margin-top: 5px;
}

If an item is inline-block and not float ing you may use vertical-align: middle .

It seems you are using a CSS framework and it is float ing, then you can use line-height: #replace this with height of the icon in px# , given that icon height is fixed. Use line-height to center text vertically with something that is taller than it.

See Plunker

Groups list text in your css file:

.grouped-list-btn-content   > .grouped-list-text {
   margin-left: 5px;
   margin-top: 9px;
}

Change the amount in margin top for example 5 should make it more centered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM