春季启动轮播全屏html,css,bootstrap

时间:2018-05-16 21:31:06

标签: html css twitter-bootstrap spring-boot thymeleaf

我有使用html和css制作全屏旋转木马的问题。当我启动我的webapp时,它只是在浏览器中显示我的内容,就像它的空白html文件一样只有顶部的glyphicon。当我在浏览器中打开它而不启动弹簧时,它工作正常。我猜我在应用程序属性或映射中遗漏了一些东西。

body {
    font-family: 'Roboto', sans-serif;
}


.carousel-fade .carousel-inner .item {
    -webkit-transition-property: opacity;
    transition-property: opacity;
}
.carousel-fade .carousel-inner .item,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
    opacity: 0;
}
.carousel-fade .carousel-inner .active,
.carousel-fade .carousel-inner .next.left,
.carousel-fade .carousel-inner .prev.right {
    opacity: 1;
}
.carousel-fade .carousel-inner .next,
.carousel-fade .carousel-inner .prev,
.carousel-fade .carousel-inner .active.left,
.carousel-fade .carousel-inner .active.right {
    left: 0;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}
.carousel-fade .carousel-control {
    z-index: 2;
}


/* carousel fullscreen */

.carousel-fullscreen .carousel-inner .item {
    height: 100vh;
    min-height: 600px;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: cover;
}


/* carousel fullscreen - vertically centered caption*/

.carousel-fullscreen .carousel-caption {
    top: 50%;
    bottom: auto;
    -webkit-transform: translate(0, -50%);
    -ms-transform: translate(0, -50%);
    transform: translate(0, -50%);
}

/* overlay for better readibility of the caption  */

.overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0.3;
    transition: all 0.2s ease-out;
}


/* typography */

h1,h2,h3,h4 {
    font-weight: 700;
}

.super-heading {
    font-size: 70px;
}


.super-paragraph {
    font-size: 30px; font-weight: 300;
}

.carousel-caption .super-paragraph a,
.carousel-caption .super-paragraph a:hover
{
    color: #fff;
}

#carousel-example-generic {
    margin: 40px 0;
}

.demo-content {padding-top: 50px; padding-bottom: 50px; }

HTML

<html>
<head>
    <title>Test</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,700' rel='stylesheet' type='text/css'>
    <link th:href="@{/css/custom.css}" rel='stylesheet' type='text/css'>
</head>
<body>

<!-- fullscreen -->

<div id="carousel-example-generic2" class="carousel slide carousel-fullscreen carousel-fade" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
        <li data-target="#carousel-example-generic2" data-slide-to="0" class="active"></li>
        <li data-target="#carousel-example-generic2" data-slide-to="1"></li>
        <li data-target="#carousel-example-generic2" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
        <div class="item active" style="background-image: url('static/1.jpg');">
            <div class="overlay"></div>
            <div class="carousel-caption">
                <h1 class="super-heading"></h1>
                <p class="super-paragraph"></p>
            </div>
        </div>
        <div class="item" style="background-image: url('static/2.jpg');">
            <div class="overlay"></div>
            <div class="carousel-caption">
                <h1 class="super-heading"></h1>
                <p class="super-paragraph"></p>
            </div>
        </div>
        <div class="item" style="background-image: url('static/3.jpg');">
            <div class="overlay"></div>
            <div class="carousel-caption">
                <h1 class="super-heading"></h1>
                <p></p>
            </div>
        </div>
    </div>

    <!-- Controls -->
    <a class="left carousel-control" href="#carousel-example-generic2" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#carousel-example-generic2" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>

控制器

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@org.springframework.stereotype.Controller
public class Controller {

    @RequestMapping(value = {"/"}, method = RequestMethod.GET)
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index");
        return modelAndView;
    }
}

的pom.xml

 <?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.demo</groupId>
        <artifactId>ritagal</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <name>Test</name>
        <description>Demo project for Spring Boot</description>

        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.0.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-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>1.9.21</version><!--$NO-MVN-MAN-VER$-->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
</dependencies>

        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>


    </project>

2 个答案:

答案 0 :(得分:0)

通过以下文件结构设法使其工作

resources
│       ├── application.properties
│       ├── static
│       │   ├── css
│       │   │   └── custom.css
│       │   └── images
│       │       ├── 1.jpg
│       │       ├── 2.jpg
│       │       └── 3.jpg
│       └── templates
│           └── index.html 

将html中的引用更改为

<link href='/css/custom.css' rel='stylesheet' type='text/css'>

<div class="item active" style="background-image: url('/images/1.jpg');">
...
在我的情况下,

application.properties为空

答案 1 :(得分:0)

我能够取得进步,根据百日咳样式对index.html进行了更改:href =“@ {/ css / custom.css}”和th:style =“'background-image:url('+ @ {/images/1.jpg} +');'“&gt; 现在一切正常。谢谢大家试图帮助我!