CSS: background-color only inside the margin

后端 未结 4 1670
梦如初夏
梦如初夏 2020-12-25 09:53

I have searched for an answer but couldn\'t find it anywhere. My question is reasonably simple: I have a background color of my body, then a large margin, and now I want a d

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-25 10:44

    If your margin is set on the body, then setting the background color of the html tag should color the margin area

    html { background-color: black; }
    body { margin:50px; background-color: white; }
    

    http://jsfiddle.net/m3zzb/

    Or as dmackerman suggestions, set a margin of 0, but a border of the size you want the margin to be and set the border-color

提交回复
热议问题