初学者:Boostrap模态在崩溃中不起作用

时间:2017-12-30 11:50:56

标签: twitter-bootstrap bootstrap-modal

你好我正在研究一个只需要使用bootstrap的学校项目。我有一个折叠元素,里面是照片,应该在点击(模态)上查看完整的图像。我直接从bootstrap站点使用了代码。然而,当我点击启动模态时,它确实出现但页面变暗但无法点击任何地方退出。

<div class="card" style="width: 100%;">

       

<p>  
    <button class="btn btn-light” type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
  <img class="d-block w-100 img-responsive" src="picA.jpg" alt="First slide">
    </button>
</p>
  <div class="card-body container center">


        <button class="btn btn-light none” type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
            <h4 class="card-title">SERIES TITLE</h4>
        </button>

        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  </div>

    <div class="collapse" id="collapseExample">
        <div class="row container" style="width: 80%; margin: 0 auto;">

            <div class="col">
                <!-- Button trigger modal -->
                <a data-toggle="modal" href="#myModal1" class="btn btn-primary btn-lg">
                    <img class="card-img-top thumb" src="https://images.pexels.com/photos/545470/pexels-photo-545470.jpeg?w=940&h=650&auto=compress&cs=tinysrgb">
                </a>

                      <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                          <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">Modal title</h4>
                              <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

                            </div>
                            <div class="modal-body">
                             <img src="https://images.pexels.com/photos/545470/pexels-photo-545470.jpeg?w=940&h=650&auto=compress&cs=tinysrgb">
                            </div>
                            <div class="modal-footer">Modal Footer Content
                              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                              <button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                          </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                      </div><!-- /.modal -->                        
            </div>

1 个答案:

答案 0 :(得分:0)

我见过你<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>DemoService</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>DemoService</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <!-- Need this to compile JSP --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 代码。没关系。可能是你应该正确检查jQuery和Bootstrap库是否加载。

正确检查负载:

html

然后你把你的HTML。我什么都没改变。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>    
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>