Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

Bootstrap Collapse with aria-expanded="true" doesn't work as expected

I use this following code to create collapse-element with Bootstrap 4.5:

    <div class="container py-2">
        <div class="row">
<button class="btn btn-success my-3" type="button" data-toggle="collapse" data-target="#collapseSelectTable" aria-expanded="true" aria-controls="collapseSelectTable">toggle element</button>
            <div class="container collapse" id="collapseSelectTable">
            <div class="row bg-light border border-info rounded align-items-center">
                <p>the table</p></div>
            </div>
        </div>
    </div>

Clicking on the button toggles the collapsed element just fine, but I expect that it should be visible 'cos "aria-expanded=true" as explained in https://getbootstrap.com/docs/4.5/components/collapse/#accessibility .

question from:https://stackoverflow.com/questions/65599270/bootstrap-collapse-with-aria-expanded-true-doesnt-work-as-expected

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The show class is needed on the collapse element to make it open by default...

"If you’ve set the collapsible element to be open by default using the show class, set aria-expanded="true" on the control instead."

https://codeply.com/p/wZCrMNXG1S


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...