Stephan
Stephan

Reputation: 411

Using a CSS in a <form action>

I am trying to do some tutorials about php and struggling with a reference to a css file. My environment is laravel as a docker container and I created a new css file named main.css in the public/css folder of laravel. The content is following:

.main-form{
    width: 450px;
    margin: auto;
}

As a next step I would like to use this information in my php file to center the labels:

<form action="" class="main-form">
            <label for="username">Username</label>
            <input type="text" name="username" id="username" class="form-control">
        </form>

However, unfortunately the css is not called and the look still stretches over the complete screen. Does anybody what I am doing wrong? Thanks Stephan

I tried css/main-form.css css.main-form

Upvotes: 0

Views: 199

Answers (1)

afikri
afikri

Reputation: 394

You need to include the correct path of your css in your view page as

<html>
   <head>
      <!-- you need to refer the main.css here-->
      <link href="{{ asset('css/main.css') }}" rel="stylesheet">
   <head>
<body>
<form action="" class="main-form">
   <label for="username">Username</label>
   <input type="text" name="username" id="username" class="form-control">
</form>
</body>
</html>

Hope it helps

Upvotes: 1

Related Questions