我正在尝试做一些有关php的教程,并努力参考css文件。我的环境是laravel作为docker容器,我在laravel的public / css文件夹中创建了一个名为main.css的新CSS文件。内容如下:
.main-form{
width: 450px;
margin: auto;
}
下一步,我想在我的php文件中使用此信息来使标签居中:
<form action="" class="main-form">
<label for="username">Username</label>
<input type="text" name="username" id="username" class="form-control">
</form>
但是,不幸的是,没有调用css,并且外观仍在整个屏幕上延伸。有人我做错了吗?
谢谢
史蒂芬
我尝试了css / main-form.css
css.main-form
最佳答案
您需要在视图页面中包含CSS的正确路径,如下所示:
<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>
希望能帮助到你
关于css - 在<form action>中使用CSS,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57010496/