简体   繁体   中英

How to center align

How to center align following html in such way that ':' should be at the center & should be listed below one another

<ul>

<li>
<label>Suomething 1 :</label> 
<span>Another 111111111111111111</span>
</li>

<li>
<label>Suomething 2222222222 :</label> 
<span>Another 2</span>
</li>

</ul>

CSS:

label{
width:25%;
display: inline-block;
width: 250px;
}

Edit:-added CSS

Try this:

label{width:170px;display:inline-block;}

Fiddle here.

You might want to use table displays:

http://jsfiddle.net/5NarV/1

CSS

ul {
    display: table;
    padding: 0;
}

li {
    display: table-row;
}

label, span {
    display: table-cell;
    width: 50%;
}

label {
    text-align: right;
}

span {
    padding-left: 0.35em;
}

HTML

<ul>
    <li>
        <label>Suomething 1 :</label> 
        <span>Another 111111111111111111</span>
    </li>
    <li>
        <label>Suomething 2222222222 :</label> 
        <span>Another 2</span>
    </li>
</ul>

It works with this CSS:

li {
    display: block;
}
label {
    width:35%;
    display: inline-block;
    text-align:right;
    float:left;
}

span {
    width:65%;
    float:right;
    display: inline-block;
}

Demo: http://jsfiddle.net/tVSte/

Like this

demo

css

ul{
    text-align:center;
}

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