How can I do width = 100% - 100px in CSS?

前端 未结 18 881
借酒劲吻你
借酒劲吻你 2020-12-12 13:28

In CSS, how can I do something like this:

width: 100% - 100px;

I guess this is fairly simple but it is a bit hard to find examples showing

18条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 13:41

    Could you do:

    margin-right: 50px;
    margin-left: 50px;
    

    Edit: My solution is wrong. The solution posted by Aric TenEyck suggesting using a div with width 100% and then nesting another div using the margins seems more correct.

提交回复
热议问题