·

CSS calc() function is not working

Published at 2024-08-28 11:53:11Viewed 108 times
Professional article
Please reprint with source link

When I was writing styles of affix, whose width needs to be set by the calc function of CSS

.fix {
  position: fixed;
  top: 20px;
  width: calc(100%-20px);

}

However, the width is not working and the calc function fail to calculate the resulting px. After searching for this problem, I finally found out that the calc function should be written like the following

.fix {
  position: fixed;
  top: 20px;
  width: calc(100% - 20px);

}

That is, two whitespaces need to be reserved before and after the arithmatic operator.

0 人喜欢

Comments

There is no comment, let's add the first one.

弦圈热门内容

[antd: Message] You are calling notice in render which will break in React 18 concurrent mode. Please trigger in effect instead.

I'm getting this error when using MessageWarning: [antd: Message] You are calling notice in render which will break in React 18 concurrent mode. Please trigger in effect instead.Here is my code:import { message } from 'antd'; export default function Page() { const [messageApi, contextHolder] = message.useMessage(); const res = await fetch("/api/...", { method: "POST", }); if (!res.ok) { messageApi.error("Error! Fail to login!"); } return ( <Home> ... </Home> ) }

Get connected with us on social networks! Twitter

©2024 Guangzhou Sinephony Technology Co., Ltd All Rights Reserved