Break element out of container

前端 未结 7 618
暖寄归人
暖寄归人 2021-02-02 09:00

I have all my content wrapped in a container element with a fixed width.

But I have a

that I want to \"break out\" of that container to span the
相关标签:
7条回答
  • 2021-02-02 10:04

    A better version taking the width of the container into account.

    .wrapper {
        width:300px;
        margin:0 auto;
        background:yellow;
    }
    .break {
        text-align:center;
        font-weight:bold;
        background:rgba(255,0,0, 0.5);
        margin-left: calc((-100vw + 300px)*.5);
        margin-right: calc((-100vw + 300px)*.5);
    }
    

    https://jsfiddle.net/Lxnmr01h/

    0 讨论(0)
提交回复
热议问题