我用render controller (Twig)在HTML內容中添加了一個表單,但是。對于該特定內容,css樣式不會被識別,對于其余內容,沒有問題。
HTML放在一個名為footer.html的文件中,內容如下:
{% apply inline_css %}
<footer id="footer">
<div class="footer-newsletter">
<div class="container">
<div class="row">
<div class="col-lg-6">
<h4>Our Newsletter</h4> <p>Tamen quem nulla quae legam multos aute sint culpa legam noster magna</p>
</div>
<div class="col-lg-6"> {{ render(controller(
'App\\Controller\\SubscribeController::new'
)) }}
</div>
... etc
{% endapply %}
我將這個文件添加到一個Twig模板中,包含:
...
{% include 'footer.html' %}
...
當我在瀏覽器中測試該頁面時,它很好地生成了表單,但是使用{ { render(Controller(' App \ \ Controller \ \ subscribe Controller::new ')} }創(chuàng)建的內容的樣式沒有應用。
在下一個代碼片段中,我將生成的HTML和。css和樣式確實適用于這里。我想知道為什么它們在直接測試頁面時不適用,以及我應該做些什么來使它們適用。
#footer {
background: #404040;
padding: 0 0 30px 0;
color: #fff;
font-size: 14px
}
#footer .footer-newsletter {
padding: 50px 0;
background: #404040
}
#footer .footer-newsletter h4 {
font-size: 24px;
margin: 0 0 20px 0;
padding: 0;
line-height: 1;
font-weight: 600
}
#footer .footer-newsletter form {
margin-top: 30px;
background: #fff;
padding: 6px 10px;
position: relative;
border-radius: 50px
}
#footer .footer-newsletter form button#subscribe_Suscribir {
position: absolute;
top: 0;
right: 0;
bottom: 0;
border: 0;
background: none;
font-size: 16px;
padding: 0 30px;
margin: 3px;
background: #e96b56;
color: #fff;
transition: 0.3s;
border-radius: 50px
}
#footer .footer-newsletter form input[type="submit"]:hover {
background: #e6573f
}
#footer .footer-top {
background: #3b3b3b;
border-top: 1px solid #474747;
border-bottom: 1px solid #474747;
padding: 60px 0 30px 0
}
#footer .footer-top .footer-info {
margin-bottom: 30px
}
#footer .footer-top .footer-info h3 {
font-size: 18px;
margin: 0 0 20px 0;
padding: 2px 0 2px 0;
line-height: 1;
font-weight: 700
}
#footer .footer-top .footer-info p {
font-size: 14px;
line-height: 24px;
margin-bottom: 0;
font-family: "Raleway", sans-serif;
color: #fff
}
#footer .footer-top .social-links a {
font-size: 18px;
display: inline-block;
background: #545454;
color: #fff;
line-height: 1;
padding: 8px 0;
margin-right: 4px;
border-radius: 50%;
text-align: center;
width: 36px;
height: 36px;
transition: 0.3s
}
#footer .footer-top .social-links a:hover {
background: #e96b56;
color: #fff;
text-decoration: none
}
#footer .footer-top h4 {
font-size: 16px;
font-weight: bold;
color: #fff;
text-transform: uppercase;
position: relative;
padding-bottom: 12px
}
#footer .footer-top .footer-links {
margin-bottom: 30px
}
#footer .footer-top .footer-links ul {
list-style: none;
padding: 0;
margin: 0
}
#footer .footer-top .footer-links ul i {
padding-right: 2px;
color: #ec7f6d;
font-size: 18px;
line-height: 1
}
#footer .footer-top .footer-links ul li {
padding: 10px 0;
display: flex;
align-items: center
}
#footer .footer-top .footer-links ul li:first-child {
padding-top: 0
}
#footer .footer-top .footer-links ul a {
color: #fff;
transition: 0.3s;
display: inline-block;
line-height: 1
}
#footer .footer-top .footer-links ul a:hover {
color: #e96b56
}
#footer .footer-top .footer-contact {
margin-bottom: 30px
}
#footer .footer-top .footer-contact p {
line-height: 26px
}
#footer .copyright {
text-align: center;
padding-top: 30px
}
#footer .credits {
padding-top: 10px;
text-align: center;
font-size: 13px;
color: #fff
}
label.required:before {
content: "*";
}
#subscribe_email {
color: red;
border: 0;
padding: 8px;
width: calc(100% - 140px)
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello PostController!</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>??</text></svg>">
<link rel="stylesheet" href="/build/app.css">
<script src="/build/runtime.js" defer=""></script>
<script src="/build/vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_bootstrap_dist_js_boo-e61552.js" defer=""></script>
<script src="/build/app.js" defer=""></script>
</head>
<body>
<div class="example-wrapper">
<h1>Hello Hello world!! ?</h1>
This friendly message is coming from: Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
</div>
<footer id="footer">
<div class="footer-newsletter">
<div class="container">
<div class="row">
<div class="col-lg-6">
<h4>Our* Newsletter</h4>
<p>Tamen quem nulla quae legam multos aute sint culpa legam noster magna</p>
</div>
<div class="col-lg-6">
<form name="subscribe" method="get" action="/subscription">
<div class="my-custom-class-for-errors">
</div>
<div class="row">
<div class="col" id="id-email">
<div>
<label for="subscribe_email" class="required">Email</label><input type="email" id="subscribe_email" name="subscribe[email]" required="required" value="ac@gmail.com">
</div>
</div>
</div>
<div><button type="submit" id="subscribe_Suscribir" name="subscribe[Suscribir]">Suscribir</button></div>
<input type="hidden" id="subscribe__token" name="subscribe[_token]">
</form>
</div>
</div>
</div>
</div>
<div class="footer-top">
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-6 footer-links">
<h4>Useful Links</h4>
<ul>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Home</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">About us</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Services</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Terms of service</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Privacy policy</a>
</li>
</ul>
</div>
<div class="col-lg-3 col-md-6 footer-links">
<h4>Our Services</h4>
<ul>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Web Design</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Web Development</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Product Management</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Marketing</a>
</li>
<li>
<i class="bx bx-chevron-right"></i> <a href="#">Graphic Design</a>
</li>
</ul>
</div>
<div class="col-lg-3 col-md-6 footer-contact">
<h4>Contact Us</h4>
<p> A Street <br> New York, NY 535000<br> United States <br><br> <strong>Phone:</strong> +1 55<br> <strong>Email:</strong> info@example.com<br> </p>
</div>
<div class="col-lg-3 col-md-6 footer-info">
<h3>About Me</h3>
<p>Cras fermentum odio eu feugiat lide par naso tierra. Justo eget nada terra videa magna derita valies darta donna mare fermentum iaculis eu non diam phasellus.</p>
<div class="social-links mt-3"> <a href="#" class="twitter"><i class="bx bxl-twitter"></i></a> <a href="#" class="facebook"><i class="bx bxl-facebook"></i></a> <a href="#" class="instagram"><i class="bx bxl-instagram"></i></a> <a href="#" class="linkedin"><i class="bx bxl-linkedin"></i></a> </div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="copyright"> ? Copyright <strong><span>Me</span></strong>. All Rights Reserved </div>
<div class="credits"> Designed by <a href="#">Me</a> </div>
</div>
</footer>
</body>
</html>
下一篇vue大屏頁面