CSS value as mathematical expression

前端 未结 4 1149
一向
一向 2021-02-07 07:30

Is there anyway that I can write a css value as mathematical expression? Example:

div{
    height: 50% + 30px;
    width: 40em - 5px;
   }

If t

4条回答
  •  有刺的猬
    2021-02-07 07:41

    Both padding and margin can be used to add to the dimensions of objects. I suggest you read up on the box model.

    HTML:

    ...

    CSS:

    .wrapper { 
        width: 40em;
        height: 50%;
        padding: 15px 0; /* Top and bottom padding of 15px */ }
    
    /* Block-level element will take up 100% of the 
      container width, minus {margin_right} + {marign_left} */
    .wrapper > div { margin: 0 0 0 5px; }
    

提交回复
热议问题