简体   繁体   中英

Modal doesn't gets focused

I was trying to use a modal. When I try to click the modal, it doesn't get focused. I'm calling the modal in the top bar navigation that is dropdown(located in the top right side). I have uploaded a photo, the link is under the code. I'm using bootstrap. I got the snippet from here

My code:

<ul class="nav navbar-right top-nav">
    <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin User <b class="fa fa-angle-down">
            </b></a>
        <ul class="dropdown-menu">
            <!--=====HERE IS WHERE I CALL THE MODAL=====-->
            <li>
                <a href="#" data-toggle="modal" data-target="#changeProfile"><i class="fa fa-fw fa-cog">
                    </i> Change Profile</a>
            </li>
            <li class="divider">
            </li>
            <li>
                <a href="#"><i class="fa fa-fw fa-power-off">
                    </i> Logout</a>
            </li>
        </ul>
    </li>
</ul>
<!-- Modal Add Brand -->
<div class="modal fade" id="changeProfile" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3>
                    Change Profile
                </h3>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="txtBusName" class="col-sm-2 control-label">Username</label>
                        <div class="col-sm-10">
                            <input type="text" id="txtUsername" class="form-control">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="txtBusDesc" class="col-sm-2 control-label">Password</label>
                        <div class="col-sm-10">
                            <input type="password" id="txtPassword" class="form-control">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">Submit</button>
            </div>
        </div>
    </div>
</div>
<!-- Modal Add Brand -->

This is what it looks like. I can't click the modal at all.

Thanks!

Seems like your modal box's z-index value is lower than the half-transparent dark div that is used to "block" the page content. Try increasing your modal box's z-index value.

#changeProfile {
  z-index: 9999;
}

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