Can i use Calc inside Transform:Scale function in CSS?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 10:26:01

Scale should be a float between 0 and 1. Use transform: scale(calc(1 / 2)) instead: https://jsfiddle.net/L1w7501o/

Try this calc() works both with hover selector and without that too. But you need to use value that are already assigned to them, like for scale(0,1) you have to use value between 0 and 1. Same for translate you have to use px or % value.

.any{
     height:250px; /*this value can change dinamically */
     background:#f22;
    transform:translate(calc(100px - 50px));
   }
   .any:hover{
   transform:translate(calc(100px - 80px)); /*is using height value*/
   }

Scale

  .any:hover{
       transform:scale(calc(1/2));
}

you can use calc but you cannot use percentage in transform:scale

but just think that 1 = 100% so if the value of 100% changes , the value of 1 will change also

for eg : if 100% = 450px and then that value changes to 250px , the value of 1 = 250px = 100%

see here jsfiddle

code :

.parent {
 width:200px;
 background:blue;
 height: 100%;

}

.child {
  transform:scale(calc(1/2));
  background:red;
}

if you REALLY want to use percentage , you have to use JQ

or you can give us a working example where you think you need only percentage

EDIT :

for your example . use this

.et_pb_portfolio_item:last-child .et_pb_portfolio_image.landscape > div {
   background-position:center center!important;
   width:100%!important;
   height:100%!important;   

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!