How do I scale an SVG background-image without honoring aspect ratio in Firefox?

前端 未结 2 1964
太阳男子
太阳男子 2021-02-19 11:46

I\'ve got a CSS background-image set on an element of fluid height and width. It\'s an SVG, and the intended behavior is for it to stretch in whatever directions ne

2条回答
  •  鱼传尺愫
    2021-02-19 12:05

    Note ... you might be better off not using the base64 encoded version of the background ... as so:

    .blog-title {
        background: none;
        color: #fff;
        font: normal normal 4em "Alternate Gothic", sans-serif;
        margin: 0 0 0 .1em;
    }
    
    .blog-title-wrapper {
        margin: -1px 0 0 0;
        padding-bottom: 20%;
        background: #333;
        background-size: 100% auto;
        background-image: url("data:image/svg+xml;charset=UTF-8, %3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 1333 750'%3E%3Cpath fill='%23d23e2c' d='M0 0h1333v320.5l-72.7 48.4 52.5 37-126.3 53 50 136-20 37-39.3-12-38.8 40.4-63.3-12-30-135.7-8 3 25 141-38 30.3-44-3-36 23.4-48.7-13-39-141-10.5 3.6 6.2 149-34 20.5-25-14-22.7 31-27.3-22-32 24-30-28L665 563l-17 1-22 159.4-29 25.4h-2l-28-23-23.3 14-21.7-21-22 11.6-24-23.4 10-155-4.8-2.2-33.6 158-30 14.2-8.8-1-35.2-20.5-34 10.2-8.8-3-33-27 25-151.7-10.6-2-45.6 140-32.6 16-55.2-40.5-39 9-33-34 46.5-132L8.8 429l55-47.8L0 333z'/%3E%3Cpath fill='%23a83123' d='M302.8 34.6L465 159l-42 208.4-145.7-83.2-95.5 48.5L81.6 143zM1079 40l196.8 78-110 253-104-60-15.2 1.8-119 49.3L902 135zM605.6 322.7l3.6 107.2-100.7 1 64.5-33zm113 2.6l33.2 77 79.5 28.3-120 19.5z'/%3E%3C/svg%3E");
    }

    {Title}

提交回复
热议问题