本文介绍了CSS:中心文本水平和垂直?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的网站,我需要知道的东西(将显示的例子)。

Im creating a new website and i need to know something(will show with example).

我说:我这样做:

html;

<div id="center-in-bar">
   <ul>
       <li>content..</li>
       <li>content..</li>
       <li>content..</li>
       <li>content..</li>
</div>

和css:

#center-in-bar {
   list-style:none;
   display:inline-block;
   /*what to do to make all the li elements centered both horizontal and vertical? in the center-in-bar element*/
}

所有李元素都以水平和垂直为中心?在中心中心元素?

What do I do to make all the li elements centered both horizontal and vertical? In the center-in-bar element?

任何帮助都会被推荐:))

Any help would be appriciated :))

推荐答案

尝试此CSS代码段:

#center-in-bar ul {
    ...
    text-align:center; /* center horizontally */
    vertical-align:middle; /* center vertically */
    ...
}
#center-in-bar li {
    ...
    display:inline; /* you might want to use this instead of "inline-block" */
    ...
    text-align:center; /* center horizontally */
    vertical-align:middle; /* center vertically */
    ...
}

这篇关于CSS:中心文本水平和垂直?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 04:31