CSS在Velocity模板(JAVA中)中未呈现

huangapple go评论66阅读模式
英文:

Css not rendering in velocity template (JAVA)

问题

我已经在一个文件中编写了一些HTML-CSS代码,它在浏览器中运行得很好,但是当我将扩展名更改为vm(用于Apache Velocity)时,一些CSS无法正常工作。为什么Velocity无法理解这些CSS呢?

代码:

<html>
<head>
    <title>Letter</title>
    <style>
    .row {
        width: 100%;
        display: flex;
        height: 80px;
    }
    .column1 {
        width: 33%;
        float: left;
    }
    .column2 {
        width: 33%;
        float: center;
    }	
    .column3 {
        width: 33%;
        float: right;
    }
    body {
        padding: 20px;
        font-size: 12px;
        font-family: Arial, Arial Unicode MS, Quivira, sans-serif, Wingdings;
    }
    #rcorners2 {
        border-radius: 25px;
        align-items: center;
        border: 1px solid grey;
        padding: 20px;
        width: 1000px;
        height: 50px;
        display: flex;
    }
    .vl {
        border-left: 1px solid grey;
        height: 50px;
    }
    .gap {
        width: 200px;
        background: none;
        height: 200px;
        display: inline-block;
    }
    </style>
</head>
<body>
<div class="row">
    <div class="column1">
        <img src="https://www.iconfinder.com/data/icons/pictype-free-vector-icons/16/home-512.png" height="50px" width="250" />
    </div>
    <div class="column2">
        <h1 style="text-align: center;">Letter Head</h1>
    </div>
    <div class="column3">
        <h2 style="color: #AE275F; text-align: right;">SAMPLE</h2>
    </div>
</div>
<div>
<div id="rcorners2"> </div>
<div>
<p>Date </p>
<p>MAY 28, 2020</p>
</div>
<div class="gap">
</div>
<div class="vl"></div>
</div>
</body>
</html>

翻译完成。

英文:

I have written some HTML-CSS in a file, It works perfectly in the browser but when I change the extendion to vm ( for apache velocity) . some of the css doesn't work . why is velocity not able to understand the css.

CODE:

   &lt;html&gt;
&lt;head&gt;
&lt;title&gt;Letter&lt;/title&gt;
&lt;style&gt;
.row {
width: 100%;
display:flex;
height:80px;
}
.column1 {
width:33%;
float: left;
}
.column2 {
width:33%;
float: center;
}	
.column3 {
width:33%;
float: right;
}
body {
padding: 20px;
font-size: 12px;
font-family: Arial,Arial Unicode MS,Quivira,sans-serif,Wingdings;
}
#rcorners2 {
border-radius: 25px;
align-items:center;
border: 1px solid grey;
padding: 20px;
width: 1000px;
height: 50px;
display:flex;
}
.vl {
border-left: 1px solid grey;
height: 50px;
}
.gap{width:200px;background:none;height:200px;display:inline-block;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;column1&quot;&gt;
&lt;img src=&quot;https://www.iconfinder.com/data/icons/pictype-free-vector-icons/16/home-512.png&quot; height=&quot;50px&quot; width=&quot;250&quot; /&gt;
&lt;/div&gt;
&lt;div class=&quot;column2&quot;&gt;
&lt;h1 style=&quot;text-align: center;&quot;&gt; Letter Head&lt;/h1&gt;
&lt;/div&gt;
&lt;div class=&quot;column3&quot;&gt;
&lt;h2 style=&quot;color:#AE275F;text-align: right;&quot;&gt;SAMPLE&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div id=&quot;rcorners2&quot; &gt; &lt;/div&gt;
&lt;div&gt;
&lt;p&gt;Date &lt;/p&gt;
&lt;p&gt;MAY 28,2020&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;gap&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;vl&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

答案1

得分: 3

问题不在于我的速度模板。我正在使用Itext5将HTML转换为PDF,由于Itext5不支持HTML5,因此某些功能无法正常工作。
我正在使用openHtmlToPdf库将HTML转换为PDF,现在CSS可以完美地工作。

英文:

The problem was not with my velocity template. I was using Itext5 to convert HTML to PDF and as Itext5 does not support HTML5 , some of the features weren't working.
I am using openHtmlToPdf library for converting HTML to PDF and the css works perfectly now.

huangapple
  • 本文由 发表于 2020年9月15日 14:03:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/63896007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定