无法使 link 垂直对齐

Can't get the link to vertical align

我正在尝试创建一个语言栏投放器,它将显示指向我网站的其他版本的链接。到目前为止,我有:

<div id="lang_dropper_wrapper">
    <img src="http://www.chambresdhotesdev.org/new_design/blank.gif" class="sprite-luna">
    <b class="down_arrow" style="float: right;">&nbsp;</b>
    <div id="lang_dropper">
        <a class="smaller lang-en" href="#">English</a>
        <a class="smaller lang-fr" href="#"> French</a>
        <a class="smaller lang-es" href="#">Cases rurals</a>
        <a class="smaller lang-mobile" href="#">Mobile</a>
    </div>
</div>

...然后是 CSS:

.lang-en:before, .lang-es:before, .lang-fr:before,.lang-mobile:before {
    content: ' ';
    /*background: url(/new_design/sprites-all-2.png) no-repeat;*/
    width: 32px;
    height: 26px;
    display: inline-block;
    margin-right: 20px;
}

.lang-en:before {
    background: green
}

.lang-es:before{
    background: red;
}

.lang-fr:before{
    background: yellow
}

.lang-mobile:before{
    background: maroon;  
}

#lang_dropper a:link {
    display:block;
    padding: 5px 5px 5px 10px;
    font-size: 12px;
    line-height: 30px;
    text-align: middle;
}
#lang_dropper a:hover {
    text-decoration: none;
    background: #eee;
}
#lang_dropper {
    position: absolute;
    top: 28px;
    left: 0px;
    z-index: 10000000;
    /*display: none;*/
    float: left;
    min-width: 160px;
    padding: 5px 0px;
    margin: 2px 0px 0px;
    background-color: #FFF;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
    background-clip: padding-box;
    width: 200px;
}
#lang_dropper_wrapper {
    position: relative;
    width: 45px;
    float: left;
    margin-right: 3px;
    margin-top: 2px;

}
#lang_dropper_wrapper:hover {
    cursor: pointer;
}

我实际上为旗帜图标使用了一个 CSS sprite - 因此其中的混淆内容与 :before 内容,以及每个图标的 class。

我唯一剩下的问题 - 是让出血的东西垂直对齐!

您可以在此处查看工作示例:

http://codepen.io/anon/pen/BjQgRe

除了我希望文本与它们左侧的旗帜彩色图标垂直对齐之外,它工作得很好

我尝试了各种方法,但就是无法正常工作。

建议?

谢谢!

为您的内联块元素应用 vertical-align:middle

.lang-en:before, .lang-es:before, .lang-fr:before,.lang-mobile:before {
content: ' ';
width: 32px;
height: 26px;
display: inline-block;
margin-right: 20px;
vertical-align:middle; /* Add this style */
}

DEMO

它被 default.so 占用了显示块,实际上如果你不给它也没关系。

li a 
{
    display: block;
}
<body>
<style>
ul {
   list-style-type: none;
   margin: 0;
   padding: 0;
  }
</style>
<div id="lang_dropper_wrapper">
<img src="http://www.chambresdhotesdev.org/new_design/blank.gif" class="sprite-luna">
<b class="down_arrow" style="float: right;">&nbsp;</b>
<div id="lang_dropper">
    <ul>
    <li><a class="smaller lang-en" href="#">English</a></li>
    <li><a class="smaller lang-fr" href="#"> French</a></li>
    <li><a class="smaller lang-es" href="#">Cases rurals</a></li>
    <li><a class="smaller lang-mobile" href="#">Mobile</a></li>
</div>
</div>
</body>