简体   繁体   中英

CSS Text Vertical alignment issue

I've got some text which I'm simply trying to centre (vertically, so it aligns with the buttons)

在此处输入图片说明

<div id="right">
    <div id="right_header">
        <p>Schedule</p>
        <div id="buttons">
            <button onclick="manualAddNewAppointment()">New appointment</button>
            <button onclick="manualAddNewEvent()">New event</button>
            <button onclick="NewClient()">New client</button>
        </div>
    </div>
    <div style="word-wrap: break-word; overflow: hidden; padding-left: 5px; padding-right: 5px; padding-top: 5px;">
    </div>
</div>

#right{
    height: 100%;
    overflow: hidden;
}
#right_header {
    padding: 2px 0;
    padding-right: 5px;
    border-bottom: 1px solid #D9D9D9;
    overflow: hidden;
    vertical-align: middle
}
#right_header p {
    float: left;
    padding-left: 15px;
    margin: 0;
    font-family: "Lucida Sans", "Lucida Sans Unicode", "Lucida Grande", "tahoma", Verdana, sans-serif;
    font-weight: bold;

}

Any ideas about what I'm doing wrong?

You can add a margin or a padding to your p element.

Try:

#right_header p {
    float: left;
    padding-left: 15px;
    margin: 0;
    font-family: "Lucida Sans", "Lucida Sans Unicode", "Lucida Grande", "tahoma", Verdana, sans-serif;
    font-weight: bold;
    margin-top:4px;
}

DEMO

do something like

#right_header p {
   line-height: 40px; //adjust the 40 accoringly
}

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