Div width 100% minus fixed amount of pixels

后端 未结 10 2064
猫巷女王i
猫巷女王i 2020-11-28 17:57

How can I achieve the following structure without using tables or JavaScript? The white borders represent edges of divs and aren\'t relevant to the question.

10条回答
  •  渐次进展
    2020-11-28 18:24

    The usual way to do it is as outlined by Guffa, nested elements. It's a bit sad having to add extra markup to get the hooks you need for this, but in practice a wrapper div here or there isn't going to hurt anyone.

    If you must do it without extra elements (eg. when you don't have control of the page markup), you can use box-sizing, which has pretty decent but not complete or simple browser support. Likely more fun than having to rely on scripting though.

提交回复
热议问题