我在Laravel 5.4项目上工作,我想要一个login.blade.php
的背景图像,而不是home.blade.php
或其他网站。
如果我在所有页面上更改Body
背景,那么最好只在登录页面上执行此操作?
谢谢
如果您在登录页面中,请将课程添加到您的身体
<body class="{{ Request::path() == 'login' ? 'background-image' : '' }}"></body>
而不是为课程添加CSS
.background-image{
//your code for background image set
}
以下是一些选项:
<script type="text/javascript"> document.body.style.backgroundImage = "url('img_tree.png')"; </script>
并将其放在login.blade.php中。这是一个快速但糟糕的计划。<body @section('body-changes', '')>
在你的login.blade.php中:
@section('body-changes') style='background-color: red;' @endsection
@section('styles', '')
,然后将它放在layouts / app.blade.html中的</body>
之前,然后每当你想为你的页面创建额外的样式时
@section('styles') <style type='text/css'> your-css-here </style> @endsection
您可以查看要求的路线
<body class="{{ Request::is('/login') ? 'image' : '' }}">
然后是以下css
body.image {
}
更简单,更清洁的方法是使用laravelista的Ekko包。它为活动路由和活动URL提供支持。