iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 9
1
Modern Web

30天CSS&Bootstrap排版統整系列 第 9

Day9--首尾DIV固定,中間DIV能夠自適應高度

  • 分享至 

  • twitterImage
  •  

首尾DIV固定,中間DIV能夠自適應高度

  • 範例
.custom-font{
             top:50%;
             transform: translateY(-50%);
             font-size: 30px;
         }
.custom-content{
             top:70px;
             bottom:70px;
             left: 0px;
         }
.custom-inner{
            //內容CSS在此調整
         }
.custom-shadow{
             box-shadow: 0 -.125rem .25rem rgba(0,0,0,.075)!important;
         }
<div class="container">
        <div class="fixed-top border-bottom text-center shadow-sm" style="height: 70px;">
            <span class="custom-font position-relative d-inline-block">TOP NAV</span>
        </div>
        <div class="custom-content position-absolute overflow-auto bg-light w-100">
            <div class="custom-inner p-3">
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p> 
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
                <p>內容</p>
            </div>
        </div>
        <div class="fixed-bottom border-top text-center custom-shadow" style="height: 70px;">
            <span class="custom-font position-relative d-inline-block">BOTTOM NAV</span>
        </div>
    </div>
  • 結果
    https://ithelp.ithome.com.tw/upload/images/20200924/20129568zThts8EOWp.png

上一篇
Day8--垂直置中(3)
下一篇
Day10--DIV自適應內容寬度,超過一定寬度即換行
系列文
30天CSS&Bootstrap排版統整30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言