gpt4 book ai didi

html - Spring boot carousel 全屏 html,css,bootstrap

转载 作者:行者123 更新时间:2023-11-28 02:31:33 26 4
gpt4 key购买 nike

我在使用 html 和 css 制作全屏轮播时遇到了问题。当我启动我的 webapp 时,它在浏览器中什么也没有显示,就像它的空白 html 文件只有顶部的 glyphicon 一样。当我在浏览器中打开它而不启动 spring 时,它工作正常。我猜我在应用程序属性或映射中遗漏了一些东西。

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>

Controller

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>

最佳答案

设法通过以下文件结构完成这项工作

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 在我的例子中是空的

关于html - Spring boot carousel 全屏 html,css,bootstrap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50380198/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com