[英]EJS: How can I make my content take up the whole screen (e.g. width: 100%)?
so I'm a beginner and I am learning HTML, CSS, JS, EJS, Express and making web apps.所以我是初学者,我正在学习 HTML、CSS、JS、EJS、Express 和制作 web 应用程序。 Basically, I'm trying to learn full stack.
基本上,我正在尝试学习全栈。 I am currently working on a web app and I'm using EJS as my templating engine as well as static HTML files for the non-dynamic parts of my web app.
I am currently working on a web app and I'm using EJS as my templating engine as well as static HTML files for the non-dynamic parts of my web app.
I can get the HTML working perfectly in EJS templates, however I'm experiencing issues getting my CSS to work.我可以让 HTML 在 EJS 模板中完美工作,但是我在让 CSS 工作时遇到问题。
I have set up routes for serving static files:我已经设置了提供 static 文件的路线:
app.set("view options", { layout: false });
app.use(express.static(__dirname + "/public"));
CSS works, seemingly perfectly except for the fact that my content doesn't take up the whole page. CSS 工作,除了我的内容没有占据整个页面这一事实之外,看起来很完美。 It's like the width: 100% property doesn't work, or maybe it does but EJS has certain constraints or something that I do not know about.
就像 width: 100% 属性不起作用,或者它可能起作用但 EJS 有某些限制或我不知道的东西。
Again, I am a beginner and I appreciate any help you can give me.同样,我是一个初学者,我很感激你能给我的任何帮助。
EJS is just an HTML-template engine, which have no difference from the usual one written by HTML(in the simplest case). EJS 只是一个 HTML 模板引擎,它与通常由 HTML 编写的引擎没有区别(在最简单的情况下)。 So, you should try to find what's wrong in your CSS styles;
所以,你应该试着找出你的 CSS styles 有什么问题;
Even if you have not configured your node server to give you the correct CSS styles, you can simply write the necessary styles inside the tag in the EJS file itself and check if everything works as expected.即使您没有配置节点服务器来为您提供正确的 CSS styles,您也可以简单地编写必要的 styles,并检查 EJS 文件本身的标签中的所有内容是否按预期工作。
Also, to check why your HTML elements do not look as intended, use the developer console in your browser.此外,要检查为什么您的 HTML 元素看起来不像预期的那样,请使用浏览器中的开发人员控制台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.