Unable to include CSS styling in handleBar templates with Node Js App(无法使用Node Js App在车把模板中包含CSS样式)
转载作者:bug小助手更新时间:2023-10-25 09:09:38274
I have a Node Js-Express Based app and using handlebars template to design a structure for Nodemailer HTML body. I tried including the CSS file multiple ways for the same, but still none of the styles are being applied to the HTML.
As the nodemailer functions and mail is received, the HTML content is rendered from the HandleBar template inside the mail body, but without any CSS or styling.
I also tried keeping the CSS file inside the same folder as the template, but no luck. Not sure where I'm going wrong. Any help to resolve the same will be highly appreciated.
that means that any so called "public" files, images, local js, style are stored in the public folder, and that is the new relative path for all headers. So no matter where your ejs or html file is, the relative path to the style sheet will always be from the top level down of your public folder. This makes it more dynamic and the only thing you have to change is:
Simple as that. Hope this makes sense, happy coding!
就这么简单。希望这是有意义的,快乐的编码!
i used internal style. i placed the css code on the head section it worked.
我用的是内部风格。我把css代码放在头部分,它起作用了。
更多回答
Thanks for the explanation. After changing, it still doesn't seem to work :/
谢谢你的解释。换了以后,似乎还是不管用:/
@enthu_dev Hey there, try just doing <link rel="stylesheet" href="style.css"> I dunno what you mean by the {{this}} tag so just flush it out with the first section in this comment.
Still not work. Though I found a weird flex. I inspected the email body HTML in the browser, and seems like even the class="" are removed from every <div> or any HTML tags, forget about including the CSS. Not understanding why is this happening. At least the class names should be there while inspecting the code.
No issues, Thank you anyway for looking into this.
没问题,不管怎样,谢谢你调查这件事。
hey, did you find any solution for this ?
嘿,你有什么办法解决这个问题吗?
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
我是一名优秀的程序员,十分优秀!