>  기사  >  웹 프론트엔드  >  Bootstrap 팝업 상자 모달 상위 레이어의 입력 상자가 포커스를 얻을 수 없는 문제 해결

Bootstrap 팝업 상자 모달 상위 레이어의 입력 상자가 포커스를 얻을 수 없는 문제 해결

高洛峰
高洛峰원래의
2016-12-24 10:43:461629검색

Bootstrap 팝업 상자의 모달 상위 레이어에 있는 입력 상자는 다음과 같습니다

1 현재 Bootstrap 프레임워크에서는 모달 팝업 상자만 가능합니다. 하나의 레이어를 지원합니다

즉, 현재 팝업 상자에서는 모달 팝업 상자를 더 이상 사용할 수 없습니다.
맞춤 팝업 상자를 사용하는 경우 예: http://my.oschina.net/tianma3798/blog/737232
맞춤 팝업 상자에 입력 입력 상자가 있는 경우, 입력 입력 상자에 초점이 맞지 않습니다. 가능한 이유는 다음과 같습니다.
팝업 레이어 정의에 많이 사용

<div class="modal fade" tabindex="0" role="dialog" id="myModal" data-backdrop="static">
 <div class="modal-dialog modal-lg">
  <div class="modal-content">
  <div class="modal-header">
   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
   <h4 class="modal-title" id="myModalLabel">添加学校</h4>
  </div>
  <div class="modal-body">
   <form class="form-horizontal" name="myForm" novalidate>
   <input type="hidden" ng-model="entity.SchID" />
   <div class="form-group">
    <label for="SchName" class="col-sm-2 control-label">学校名称:</label>
    <div class="col-sm-10">
    <input type="text" required ng-minlength="3" ng-maxlength="30"
     class="form-control"
     ng-model="entity.SchName" name="SchName" placeholder="长度3-30">
    <span class="text-danger" ng-show="myForm.SchName.$dirty && myForm.SchName.$invalid">
     <span ng-show="myForm.SchName.$error.required">名称是必须的</span>
     <span ng-show="myForm.SchName.$error.minlength">最小长度3</span>
     <span ng-show="myForm.SchName.$error.maxlength">最大长度30</span>
    </span>
    </div>
   </div>
  
   <div class="form-group">
    <label for="WebSite" class="col-sm-2 control-label">学校官网:</label>
    <div class="col-sm-10">
    <input required type="url" class="form-control" ng-model="entity.WebSite" name="WebSite"
     placeholder="链接地址" />
    <span class="text-danger" ng-show="myForm.WebSite.$dirty && myForm.WebSite.$invalid">
     <span ng-show="myForm.WebSite.$error.required">姓名是必须的</span>
     <span ng-show="myForm.WebSite.$error.url">链接格式不正确</span>
    </span>
    </div>
   </div>
  
   <div class="form-group">
    <label for="FoundTime" class="col-sm-2 control-label">建校时间:</label>
    <div class="col-sm-10">
    <input required type="number" class="form-control" ng-model="entity.FoundTime" name="FoundTime"
     placeholder="年份" />
    <span class="text-danger" ng-show="myForm.FoundTime.$dirty && myForm.FoundTime.$invalid">
     <span ng-show="myForm.Summary.$error.required">姓名是必须的</span>
     <span ng-show="myForm.Summary.$error.number">请输入数字(年份)</span>
    </span>
    </div>
   </div>
   <div class="form-group">
    <label class="col-sm-2 control-label">入学时间:</label>
    <div class="col-sm-10">
    <div class="selectBox" id="selectMonth"></div>
    <input type="hidden" name="Province" ng-model="entity.MonthList" />
    </div>
   </div>
   </form>
  </div>
  <div class="modal-footer">
   <button type="button" class="btn btn-success" ng-disabled="myForm.$invalid" ng-click="addOrUpdate()">保存</button>
   <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
  </div>
  </div>
 </div>
 </div>

해결책은 다음과 같습니다. tabindex="0" 속성을 제거하면 포커스를 얻을 수 있습니다

b7a1a52fcacd57bf709e405c19976454

Bootstrap 팝업 상자 모달의 상위 레이어에 있는 입력 상자가 포커스를 얻을 수 없는 문제를 해결하는 방법에 대한 자세한 관련 기사를 보려면 다음을 주의하십시오. PHP 중국어 웹사이트!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.