简体   繁体   中英

AnythingSlider: Vertical align middle text

I am using the AnythingSlider JQuery Content slider and am having a hard time trying to vertically center in the middle a piece of text. I have tried the following but doesn't work.

<li>
    <div style="display:table-cell; vertical-align:middle;"> 
        <h1> THIS IS A TEST!! </h1> 
    </div>
</li>

Do your li-elements have a fixed height? If so you could try using CSS and add "line-height: (same height as li)" and "vertical-align: middle".

(By the way, I don't think you should be using divs inside a li)

working example: http://jsfiddle.net/jc7CE/

CSS:

li{
float: left;
height: 100px;
width: 100px;
line-height: 100px;
vertical-align: middle;
border: 1px solid red;
padding: 10px;
}

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