Python 无法在CSS中调整图像大小

Python 无法在CSS中调整图像大小,python,css,flask,weasyprint,Python,Css,Flask,Weasyprint,我正在通过Flask开发一个网页,并希望使用WeasyPrint生成PDF 我知道flask需要静态url来定义我的css文件,并在css中包含@media print from <link rel=stylesheet href="{{ url_for('static', filename='css/style.css') }}"> to <link rel=stylesheet href="{{ url_for('static', filename='css/pri

我正在通过Flask开发一个网页,并希望使用WeasyPrint生成PDF

我知道flask需要静态url来定义我的css文件,并在css中包含@media print

from 
<link rel=stylesheet href="{{ url_for('static', filename='css/style.css') }}">

to 

<link rel=stylesheet href="{{ url_for('static', filename='css/print.css') }}" media= "print" >

@media print {
logo{
       width : 50px !important;
       height : 100px !important;
       object-fit: cover;
  }
}


但是它并没有按照我的要求显示调整大小的图像。

此命令在weasyprint上不起作用

您需要在Html文件中使用CSS

就像这样:

<style> /* use CSS into style */
      @page {
        size: A4; /* Change from the default size of A4 */
        margin: 3.5mm; /* Set margin on each page */
      }
       .IMAGE{
        height: 120px;
        width: 120px;
        margin: 0 auto;
       }            
</style>
再见