这是我的 DefaultController.php 我无法查看我所包含的所有css和js文件。我的错误将在我的内部CSS中,我在我们的twig文件中提到过。
enter image description here
enter image description here
<?php
namespace AppBundle\Controller;
use AppBundle\Entity\users;
use AppBundle\Entity\Login;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
class DefaultController extends Controller
{
/**
* @Route("/timeline", name="timeline")
*/
public function timelineAction(Request $request)
{
return $this->render('default/timeline.html.twig');
return $this->redirectToRoute('timeline');
}
}
这是我的 timeline.html.twig 文件,我不知道如何在树枝中使用内部css
{% extends "::base.html.twig" %}
{% block stylesheets %}
<style>
div {
padding-bottom:20px;
}
</style>
{% endblock %}
{% block body %}
<hr />
<div class="container">
<div class="page-header">
<h1 id="timeline">User Events</h1>
</div>
<ul class="timeline">
<li>
<div class="timeline-badge info"><i class="fa fa-unlock"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">User Logged in</h4>
<span><i class="fa fa-clock-o fa-2x"></i> 1 hour 20 minutes ago</span>
<hr />
</div>
<div class="timeline-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge success"><i class="fa fa-search"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">User Content Search</h4>
<span><i class="fa fa-clock-o fa-2x"></i> 57 minutes ago</span>
<hr />
</div>
<div class="timeline-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
</div>
</li>
<li>
<div class="timeline-badge danger"><i class="fa fa-shopping-cart"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">Items added to shopping cart</h4>
<span><i class="fa fa-clock-o fa-2x"></i> 37 minutes ago</span>
<hr />
</div>
<div class="timeline-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge info"><i class="fa fa-dollar"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">Payment processed</h4>
<span><i class="fa fa-clock-o fa-2x"></i> 27 minutes ago</span>
<hr />
</div>
<div class="timeline-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
</div>
</li>
<li class="timeline-inverted">
<div class="timeline-badge info"><i class="fa fa-share"></i></div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">User logged out</h4>
<span><i class="fa fa-clock-o fa-2x"></i> 10 minutes ago</span>
<hr />
</div>
<div class="timeline-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</p>
</div>
</div>
</li>
</ul>
</div>
</div>
{% endblock %}
答案 0 :(得分:1)
您没有显示您的base.html.twig,但您可能有类似
的内容...
{% block stylesheets %}
<link type="text/css" href="mycss1.css">
<link type="text/css" href="mycss2.css">
{% endblock %}
...
所以在你的timeline.html.twig中你必须在样式表块的开头添加{{ parent() }}
,在你的情况下
{% block stylesheets %}
{{ parent() }}
<style>
div {
padding-bottom:20px;
}
</style>
{% endblock %}