在我们的全局 css 文件中,我们可以这样编写 css
:root{
--orange:#e67e22;
--black:#333;
--light-color:#777;
--border:.1rem solid rgba(0,0,0,.2);
--box-shadow:0 .5rem 1rem rgba(0,0,0,.1);
}
*{
margin:0; padding:0;
box-sizing: border-box;
outline: none; border:none;
text-decoration: none;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-weight: lighter;
}
html{
font-size: 62.5%;
overflow-x: hidden;
scroll-behavior: smooth;
scroll-padding-top: 6rem;
}
section{
padding:2rem 7%;
}
Run Code Online (Sandbox Code Playgroud)
但我们不能在组件 module.css 中编写这个 css。我需要编写.section而不是section,但如果我在组件 module.css 中编写.section 而不是section,我的风格就会被破坏。有什么方法可以像全局 css 一样在我的 module.css 中编写这些 css 吗?
像这样在我们的组件中应用自定义样式也是痛苦且耗时的{style.ClassName}。有没有简单或快速的方法可以在我们的组件中应用自定义样式?
我正在使用图像压缩来减小图像大小。提交帖子请求时,我没有收到任何错误,但无法弄清楚为什么图像没有保存。这是我的代码:
@app.post("/post_ads")
async def create_upload_files(title: str = Form(),body: str = Form(),
db: Session = Depends(get_db), files: list[UploadFile] = File(description="Multiple files as UploadFile")):
for file in files:
im = Image.open(file.file)
im = im.convert("RGB")
im_io = BytesIO()
im = im.save(im_io, 'JPEG', quality=50)
Run Code Online (Sandbox Code Playgroud)