LoginSignup
0
0

More than 5 years have passed since last update.

PlayFrameworkでBootStrapを利用する方法

Posted at

play-bootstrapという便利なライブラリがあるのでそちらを利用する

環境

play 2.5.10
java

build.sbt

"com.adrianhurt" %% "play-bootstrap" % "1.2-P25-B3-RC2"を追加する
P25-B3とはplay2.5系のbootstrap3を利用するという意味

libraryDependencies ++= Seq(
  ...
  "com.adrianhurt" %% "play-bootstrap" % "1.2-P25-B3-RC2"
)

app/views/main.scala.html

<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">をメインのhtmlに追加してあげる


<!DOCTYPE html>
<html lang="en">
    <head>
        @* Here's where we render the page title `String`. *@
        <title>@title</title>
        <link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
        <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
        <link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
        <script src="@routes.Assets.versioned("javascripts/hello.js")" type="text/javascript"></script>
    </head>
    <body>
        @* And here's where we render the `Html` object containing
         * the page content. *@
        @content
    </body>
</html>

app/views/index.scala.html

@(message: String)
@import b3.vertical.fieldConstructor

@main("index") {    
    @b3.buttonType("submit", 'class -> "btn btn-default"){ <span class="glyphicon glyphicon-ok"></span> Login }
}

完成

スクリーンショット 2018-03-21 18.37.31.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0