It is invalid for css: to use line-height to achieve vertical centering.

New self-study, recently encountered a problem, sometimes line-height can not achieve the center.
other methods can be used here, but I want to find out why line-height cannot be used.
if line-height is added here, only the content of the a tag will be centered vertically

html

    <div class="topbar-search">
        <input type="text" id="search">
        <a href="-sharp"></a>
    </div>

css:

.site-topbar. Topbar-search {

float: right;
line-height:55px;
width: 315px;
height: 55px;
background: url(img/task09-sprite.png) no-repeat 0px -37px;

}
. Site-topbar. Topbar-search a {

display: inline-block;
margin-top: 5px;
margin-left: 25px;
width: 16px;
height: 16px;
background: url(img/task09-sprite.png) no-repeat -45px -2px;

}

effect:

Mar.01,2021

one:
you center it by adding a few words in front of the text box. (stubborn bug)

<div class="topbar-search">
`` <input type="text" id="search">
 <a href="-sharp"></a>
 </div>                 //line-height 
 

two:
or use margin-top to calculate the distance to achieve the effect


where can I add line-height ?

line-height is also affected by the parent's css attribute image. Certain types of elements also behave differently
see http://www.zhangxinxu.com/wor.


sensation is related to vertical-align


this kind of centered feeling plus vertical-align:middle

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea7903-1e6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea7903-1e6c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?