Why doesn't the CSS calc() function work for me?

前端 未结 9 1504
小鲜肉
小鲜肉 2020-11-30 11:24

I learned about the CSS function calc() and its awesome. I tried to use it like:

#abc{width:calc(100%-20px)}
<         


        
9条回答
  •  隐瞒了意图╮
    2020-11-30 11:47

    IE9's implementation of the calc() method doesn't work on elements which are display: table.

    You can work around this by wrapping a div around it (which is display: block) and making the width of the display: table element inside width: 100%. You apply the calcd width to the surrounding div.

提交回复
热议问题