008、垂直對齊

1、垂直對齊:使用在行內元素

<style type="text/css">
#box1{
    border: 1px solid gray;
    height: 300px;
    text-align: center;
    line-height: 300px;
    font-size: 3rem;
}
</style>
<div id="box1">
    今天天氣不錯!
</div>

今天天氣不錯!

2、垂直對齊:使用在區塊元素

<style type="text/css">
#box1{
    border: 1px solid gray;
    height: 300px;
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
#box2{
    border: 3px solid lime;
    background-color: yellow;
    height: 100px;
    width: 300px;
    text-align: center;
}
</style>
<div id="box1">
    <div id="box2">今天天氣不錯!</div>
</div>

今天天氣不錯!
shape
shape