第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使父級 Div 高度與子級相同

使父級 Div 高度與子級相同

慕桂英3389331 2024-01-22 14:25:48
我有一個容器 div,里面有另外兩個 div。一個是顯示在左側(cè)的“Home”,另一個是顯示在右側(cè)的“Away”。他們肩并肩。這些 div 內(nèi)部是其他 div,并且有 Javascript,因此當(dāng)按下某個元素時,它會使用 CSS 顯示來顯示/隱藏其他 div。但是,當(dāng)我隱藏/取消隱藏這些時,父級高度不會調(diào)整,因此一旦打開多個 div,您就看不到顯示的 div。下面的例子:$("document").ready(function () {    setupInjuries();});function setupInjuries() {    $(".match-injury").each(function () {        var helpIcon = $(this).find(".match-injury-icon");        var shortDescription = $(this).find(".match-injury-shortdescription");        var latestButton = $(this).find(".match-injury-latestbutton");        var longDescription = $(this).find(".match-injury-longdescription");        helpIcon.click(function () {            if (shortDescription.css("display") == "none") {                shortDescription.css("display", "block");            }            else {                shortDescription.css("display", "none");                longDescription.css("display", "none");                latestButton.text("SEE LATEST");            }        });        latestButton.click(function () {            if (longDescription.css("display") == "none") {                longDescription.css("display", "block");                $(this).text("HIDE LATEST");            }            else {                longDescription.css("display", "none");                $(this).text("SEE LATEST");            }        });    });}如何根據(jù)子容器的高度/顯示狀態(tài)調(diào)整容器高度?
查看完整描述

1 回答

?
揚(yáng)帆大魚

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超9個贊

這是因?yàn)槟呀?jīng)為父容器指定了高度match-injuries-container。我已經(jīng)刪除了該height屬性并添加了min-height屬性,并且它對我來說工作正常。如果不需要,您甚至可以完全刪除此屬性。


$("document").ready(function () {

    setupInjuries();

});


function setupInjuries() {

    $(".match-injury").each(function () {


        var helpIcon = $(this).find(".match-injury-icon");

        var shortDescription = $(this).find(".match-injury-shortdescription");

        var latestButton = $(this).find(".match-injury-latestbutton");

        var longDescription = $(this).find(".match-injury-longdescription");


        helpIcon.click(function () {


            if (shortDescription.css("display") == "none") {

                shortDescription.css("display", "block");

            }

            else {

                shortDescription.css("display", "none");

                longDescription.css("display", "none");

                latestButton.text("SEE LATEST");

            }


        });


        latestButton.click(function () {


            if (longDescription.css("display") == "none") {

                longDescription.css("display", "block");

                $(this).text("HIDE LATEST");

            }

            else {

                longDescription.css("display", "none");

                $(this).text("SEE LATEST");

            }


        });


    });

}

.match-injuries-container {

    width: 100%;

    /* You can have min-height but not height */

    min-height: 135px; 

    background-color: #e5e5e5;

    overflow: hidden;

}


.match-injuries-home {

    width: 50%;

    float: left;

    text-align: center;

    display: inline-block;

    border-left: 1px solid #9c9c9c;

    background-color: #e5e5e5;

}


.match-injuries-away {

    width: 50%;

    float: right;

    text-align: center;

    display: inline-block;

    border-right: 1px solid #9c9c9c;

    background-color: #e5e5e5;

}


.match-injury {

    width: 100%;

    height: auto;

    background-color: #d3d3d3;

    font-size: 13px;

    font-weight: bold;

    border-bottom: 1px solid #9c9c9c;

    border: 1px solid #9c9c9c;

    border-left: none;

    cursor: default;

    position: relative;

}


.match-injury-detail {

    height: 25px;

    padding: 3px 3px 3px 3px;

}


.match-injury-player {

    color: #5b5b5b;

}


.match-injury-status {

    margin-left: 5px;

    color: #d20000;

}


.match-injury-icon {

    position: absolute;

    right: 5px;

    top: 0;

    font-size: 15px;

    color: #2b3180;

    cursor: pointer;

}


.match-injury-descriptions {

    padding: 3px 3px 3px 3px;

}


.match-injury-shortdescription {

    font-size: 10px;

    background-color: #f0f0f0;

    height: auto;

    padding: 3px 3px 3px 3px;

    font-weight: normal;

    display: none;

}


.match-injury-longdescription {

    font-size: 10px;

    background-color: #f0f0f0;

    height: auto;

    padding: 3px 3px 3px 3px;

    font-weight: normal;

    font-style: italic;

    display: none;

}


.match-injury-latestbutton {

    background-image: linear-gradient(#e5e5e5,#ffffff,#e5e5e5);

    width: 100%;

    height: 18px;

    text-align: center;

    border: 1px solid #bbbbbb;

    font-size: 10px;

    font-weight: bold;

    cursor: pointer;

    padding-top: 2px;

}


.match-injury-border {

    width: 100%;

    height: 4px;

    background-image: linear-gradient(#9a9a9a, white, #9a9a9a);

}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script src="https://kit.fontawesome.com/a076d05399.js"></script>

<div class="match-injuries-container">


    <div class="main-header-bar">Injuries</div>


    <div class="match-injuries-home">

        <div class="match-injury">

            <span class="match-injury-player">Player Name 1</span>

            <span class="match-injury-status">OUT</span>

            <div class="match-injury-icon"><i class="fa fa-info-circle"></i></div>

            <div class="match-injury-shortdescription">

                Quadricepts - Expected to be out until atleast July 1st

                <div class="match-injury-latestbutton">SEE LATEST</div>

            </div>

            <div class="match-injury-longdescription">Cousins is unlikely to return this post season, but he wont require surgery on the torn left quadriceps muscle sustained during the firsty quarter of game 2 again the Clipper's on Monday.</div>

        </div>


        <div class="match-injury-border"></div>


        <div class="match-injury">

            <span class="match-injury-player">Player Name 2</span>

            <span class="match-injury-status">OUT</span>

            <span class="match-injury-icon"><i class="fa fa-info-circle"></i></span>

            <div class="match-injury-shortdescription">

                Quadricepts - Expected to be out until atleast July 1st

                <div class="match-injury-latestbutton">SEE LATEST</div>

            </div>

            <div class="match-injury-longdescription">Cousins is unlikely to return this post season, but he wont require surgery on the torn left quadriceps muscle sustained during the firsty quarter of game 2 again the Clipper's on Monday.</div>

        </div>


        <div class="match-injury-border"></div>


        <div class="match-injury">

            <span class="match-injury-player">Player Name 3</span>

            <span class="match-injury-status">OUT</span>

            <span class="match-injury-icon"><i class="fa fa-info-circle"></i></span>

            <div class="match-injury-shortdescription">

                Quadricepts - Expected to be out until atleast July 1st

                <div class="match-injury-latestbutton">SEE LATEST</div>

            </div>

            <div class="match-injury-longdescription">Cousins is unlikely to return this post season, but he wont require surgery on the torn left quadriceps muscle sustained during the firsty quarter of game 2 again the Clipper's on Monday.</div>

        </div>

    </div>


    <div class="match-injuries-away">

        <span style="font-size:13px;">No reported injuries</span>

    </div>

</div>


查看完整回答
反對 回復(fù) 2024-01-22
  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號