2

I'm using Laravel 5.4. in my routes folder in web.php I have written the code below:

Route::get('test', function () {
    return view('test');
});

And also I have created test.blade.php inside resources/views. in this file i have a simple layout:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Testing Bootstrap</title>
  </head>
  <body>
    <div class="container bg-danger">
      <p>This is a paragraph</p>
    </div>
  </body>
</html>

In order to access this page I simply use localhost:8000/test url.

the page loads successfully, but bootstrap classes like container and bg-danger are not affected. why? How can I use bootstrap features inside a laravel blade template?

1 Answer 1

3

Except this is your first time to use bootstrap, by simply adding the link to the bootsrap file in your head as you would do other css file would do the job, An example from a cdn:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

.....

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Testing Bootstrap</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  </head>
  <body>
    <div class="container bg-danger">
      <p>This is a paragraph</p>
    </div>
  </body>
</html>

PS: My recommendation for next time: Google it, Google it... Most likely its already answered also on Stackoverflow. Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.