·

CSS calc() function is not working

Published at 2024-08-28 11:53:11Viewed 104 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.

Comments

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

弦圈热门内容

Get connected with us on social networks! Twitter

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