使用 {{ HTML}} 的 Laravel 4 css 和 javascript 链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18225692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 4 css & javascript link using {{ HTML}}
提问by vikaskimt
I am beginner in Laravel 4 and I have include css file using HTML class but it's not working so please help me. My code is :-
我是 Laravel 4 的初学者,我使用 HTML 类包含了 css 文件,但它不起作用,所以请帮助我。我的代码是:-
In view :- model_window.php
在视图中:- model_window.php
<?php HTML::style('css/style.css'); ?>
<a href="#openModal"><input type="submit" value="show" name=""show_button></a>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Modal Box</h2>
</div>
</div>
my css file :- in public -> css -> style.css
我的 css 文件:- 在公共 -> css -> style.css
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
回答by DolDurma
you can rename your file to such as index.blade.php second of that must be have blade and you can simply use:
您可以将文件重命名为例如 index.blade.php 第二个必须有刀片,您可以简单地使用:
{{ HTML::style('public/css/index.css') }}
{{ HTML::script('public/js/jquery.pnotify.min.js') }}
回答by DolDurma
you must to put files into public directory and then can easily use
您必须将文件放入公共目录,然后才能轻松使用
<?php echo HTML::style('css/style.css'); ?>
回答by Andreyco
Your view is invalid. You need to include link to .css file between tags.
你的观点是无效的。您需要在标签之间包含到 .css 文件的链接。
<!doctype html>
<html lang="en">
<head>
<?=HTML::style('link/to/style.css')?>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a href="#openModal"><input type="submit" value="show" name=""show_button></a>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Modal Box</h2>
</div>
</div>
</body>
</html>
Now, it will work.
现在,它将起作用。
回答by ciruvan
You always have to include your CSS files in the <head>
section of your HTML. That's why your styles aren't applied.
您始终必须在<head>
HTML 部分中包含您的 CSS 文件。这就是为什么不应用您的样式的原因。
And the relevant line should be:
相关行应该是:
<?php echo HTML::style('css/style.css'); ?>