简体   繁体   中英

How can I align this perfectly?

DEMO: http://jsfiddle.net/CtCuk/10/

If you take a look at demo, "Here is News" section is folded.

However I want this section in the midlle vertically, and all straight up to the right.
Then if window size gets narrowed down, it should start folding characters.

Is it possible?

HTML

<div class="top_page">
    <div class='container-general'>
        <div class="annouce-row">    
            <div class='title'>
                New
            </div>
            <div class='announcement'>
                Here is News
            </div>
        </div>
    </div>
</div>

CSS

.top_page{
    width: auto;
    max-width: 900px;
    margin: 50px auto 20px;
}

.annouce-row {
    width: 800px;
}

.annouce-row div {
    width: 100px;
   display: inline-block;
}

.title {
    padding: 20px 10px;
    background-color: rgb(123, 0, 218);
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    margin: 1px;
    color: rgb(255, 255, 255);
    font-size: 22px;
    width: 70px;
}

.announcement {
    font-size: 24px;
    font-weight: 200;
    color: rgb(0, 174, 218);
    margin-left: 0px;
    width: 600px;
}

take this 100px width out and the text will remain on the same line

.annouce-row div {
   width: 100px;    /*this line*/
   display: inline-block;
}

Have you tried adding:

display:table-cell;
vertical-align:middle;

to .announcement? This is supported in everything except IE 6 & 7.

You might want to read this before you decide on this route, however.

I think he need the width to be 100px, so just add:

.annouce-row div {
    width: 100px;
    display: inline-block;
    vertical-align: middle; //this!
}

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