SVG 粘糊糊的效果在最新版本的 FireFox 上不起作用

2024-01-07

我有一个问题,当使用黑色以外的任何其他颜色时,我的 feGuassian 模糊无法正常工作。

在 chrome 上它工作得很好。我还没有在 safari 上测试过。

我在 jsFiddle 创建了一个示例:

HTML:

<div>
<div class="bigLogo">
    <div class="blobs">
    <div class="blob"></div>
    <div class="blob"></div>
    <div class="blob"></div>
    <div class="connect12">
        <div class="part1"></div>
        <div class="part2"></div>
        <div class="part3"></div>
    </div>
    <div class="connect23">
        <div class="part3"></div>
    </div>
    <div class="connect31">
        <div class="part3"></div>
    </div>
</div>
<svg xmlns="http://www,w3.org" version='1.1'>
    <defs>
        <filter id="goo">
            <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur"/>
            <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0                                                                                       0 1 0 0 0                                                                                   0 0 1 0 0                                                                                   0 0 0 18 -7" result="goo"/>
            <feBlend in="SourceGraphic" in2="goo" />
        </filter>
    </defs>
</svg>
</div>
</div>

<div class="break">
<div class="smallLogo">
        <div class="blobs">
            <div class="blob"></div>
            <div class="blob"></div>
            <div class="blob"></div>
            <div class="connect12">
                <div class="part1"></div>
                <div class="part2"></div>
                <div class="part3"></div>
            </div>
            <div class="connect23">
                <div class="part3"></div>
            </div>
            <div class="connect31">
                <div class="part3"></div>
            </div>
        </div>

        <svg xmlns="http://www,w3.org" version='1.1'>
            <defs>
                <filter id="goo2">
                    <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur"/>
                    <feColorMatrix in="blur" mode="matrix" values="0 0 0 0 0
                                                                   0 0 0 0 0
                                                                   0 0 0 0 0
                                                                   0 0 0 18 -7" result="goo"/>
                    <feBlend in="SourceGraphic" in2="goo" />
                </filter>
            </defs>
        </svg>
    </div>
</div>

SCSS:

@-webkit-keyframes rotate-logo {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@keyframes rotate-logo {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

@-webkit-keyframes rotate-logo-small {
    0% {
        -webkit-transform: rotate(0deg) scale(0.3);
        transform: rotate(0deg) scale(0.3);
    }
    100% {
        -webkit-transform: rotate(360deg) scale(0.3);
        transform: rotate(360deg) scale(0.3);
    }
}

@keyframes rotate-logo-small {
    0% {
        -webkit-transform: rotate(0deg) scale(0.3);
        transform: rotate(0deg) scale(0.3);
    }
    100% {
        -webkit-transform: rotate(360deg) scale(0.3);
        transform: rotate(360deg) scale(0.3);
    }
}

@-webkit-keyframes blob-anim-left {
    0% {
        -webkit-transform: translateX(6px) translateY(10px);
        transform: translateX(6px) translateY(10px);
    }
    100% {
        -webkit-transform: translateX(-43px) translateY(25px);
        transform: translateX(-43px) translateY(25px);
    }
}

@keyframes blob-anim-left {
    0% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    100% {
        -webkit-transform: translateX(-43px) translateY(25px);
        transform: translateX(-43px) translateY(25px);
    }
}

@-webkit-keyframes blob-anim-right {
    0% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    100% {
        -webkit-transform: translateX(59px) translateY(-61px);
        transform: translateX(59px) translateY(-61px);
    }
}

@keyframes blob-anim-right {
    0% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    100% {
        -webkit-transform: translateX(59px) translateY(-61px);
        transform: translateX(59px) translateY(-61px);
    }
}

@-webkit-keyframes blob-anim-top-right {
    0% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    100% {
        -webkit-transform: translateX(28px) translateY(36px);
        transform: translateX(28px) translateY(36px);
    }
}

@keyframes blob-anim-top-right {
    0% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
    100% {
        -webkit-transform: translateX(28px) translateY(36px);
        transform: translateX(28px) translateY(36px);
    }
}

@keyframes line-anim-con12 {
    0% {
        -webkit-transform: translateX(-30px) translateY(-24px);
        transform: translateX(-30px) translateY(-24px);
        width: 0px;
    }
    100% {
        -webkit-transform: rotate(-37deg) translateX(-37px) translateY(-83px);
        transform: rotate(-37deg) translateX(-37px) translateY(-83px);
        width: 120px;
    }
}

@keyframes line-anim-con23 {
    0% {
        -webkit-transform: translateX(-30px) translateY(-24px);
        transform: translateX(-30px) translateY(-24px);
        height: 1px;
    }
    100% {
        -webkit-transform: rotate(13deg) translateX(19px) translateY(-46px);
        transform: rotate(13deg) translateX(19px) translateY(-46px);
        height: 25px;
    }
}

@keyframes line-anim-con31 {
    0% {
        -webkit-transform: translateX(-30px) translateY(-24px);
        transform: translateX(-30px) translateY(-24px);
        width: 1px;
    }
    100% {
        -webkit-transform: translateX(-46px) translateY(8px) rotate(25deg);
        transform: translateX(-46px) translateY(8px) rotate(25deg);
        width: 23px;
    }
}

.bigLogo{
    position: absolute;
    width: 208.8px;
    height: 208.8px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.smallLogo{
    position: absolute;
    width: 75px;
    height: 75px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);

    .blobs{
        -webkit-filter: url('#goo2') !important;
        filter: url('#goo2') !important;
        -webkit-animation: rotate-logo ease-in-out 9s infinite alternate !important;
        animation: rotate-logo ease-in-out 9s infinite alternate !important;
        .blob{
            background: #000 !important;
        }
        .part1{
            background-color: #000 !important;
        }
        .part2{
            background-color: #000 !important;
        }
        .part3{
            background-color: #000 !important;
        }
    }
}

.blobs {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 208.8px;
    height: 208.8px;
    margin: auto;
    -webkit-filter: url('#goo');
    filter: url('#goo');
    -webkit-animation: rotate-logo ease-in-out 9s infinite alternate;
    animation: rotate-logo ease-in-out 9s infinite alternate;
}

.blob {
    background: #2a4059;
    width: 50px;
    height: 50px;
    position: absolute;
    left: 50%;
    top: 60%;
    margin-top: -50px;
    margin-left: -50px;
    border-radius: 100%;
}

.blob:nth-child(1) {
    -webkit-animation: blob-anim-left ease-in-out 2.5s infinite alternate;
    animation: blob-anim-left ease-in-out 2.5s infinite alternate;
}

.blob:nth-child(2) {
    -webkit-animation: blob-anim-right ease-in-out 2.5s infinite alternate;
    animation: blob-anim-right ease-in-out 2.5s infinite alternate;
    width: 72px;
    height: 72px;

}

.blob:nth-child(3) {
    -webkit-animation: blob-anim-top-right ease-in-out 2.5s infinite alternate;
    animation: blob-anim-top-right ease-in-out 2.5s infinite alternate;
    width: 84px;
    height: 84px;
}

.line{
    width: 150px;
    height: 10px;
    margin: 150px;
    position: relative;
    filter: url('#goo');

}

.part1{
    width: 50%;
    height: 100%;
    background: #2a4059;
    transform: perspective(70px) rotateY(50deg);
    position: absolute;
    left: 0;
}

.part2{
    width: 50%;
    height: 100%;
    right: 0;
    position: absolute;
    background: #2a4059;
    transform: perspective(70px) rotateY(-50deg);
}

.part3{
    background: #2a4059;
    width: 100%;
    height: 100%;
}

.connect12{
    height: 14px;
    position: absolute;
    left: 50%;
    top: 60%;
    -webkit-animation: line-anim-con12 ease-in-out 2.5s infinite alternate;
    animation: line-anim-con12 ease-in-out 2.5s infinite alternate;
    .part3{
        height: 78% !important;
        top: 50%;
        transform: translateY(-50%);
        position: absolute;
    }
}

.connect23{
    width: 11px;
    position: absolute;
    left: 50%;
    top: 60%;
    -webkit-animation: line-anim-con23 ease-in-out 2.5s infinite alternate;
    animation: line-anim-con23 ease-in-out 2.5s infinite alternate;
}

.connect31{
    height: 11px;
    position: absolute;
    left: 50%;
    top: 60%;
    -webkit-animation: line-anim-con31 ease-in-out 2.5s infinite alternate;
    animation: line-anim-con31 ease-in-out 2.5s infinite alternate;
}

.break{
    position: relative;
    top: 350px;
}

https://jsfiddle.net/lastgiven/kqmabvxs/2/ https://jsfiddle.net/lastgiven/kqmabvxs/2/

如果有人可以看看他们是否可以帮助我解决这个问题,我将非常感激。

提前致谢


“粘糊效应”似乎是通过这篇关于 css-tricks 的文章 https://css-tricks.com/gooey-effect/。虽然它很好地描述了它的工作原理,但它未能探索 SVG 过滤器为制定过滤器提供的不同可能性。目前看来,过滤器原语的不同实现以及 SVG 或 HTML 命名空间中元素的应用程序在跨浏览器的渲染方面存在差异。

让我首先解释一下可能性,然后提供一个跨浏览器比较的测试用例。

模糊输入图形

过滤器开始于

<feGaussianBlur stdDeviation="20" />

产生模糊的图像。虽然它“涂抹”不同的颜色,但其主要目的是沿着 Alpha 颜色值变化的图形源的边界生成宽带像素。你走得越远,部分透明度就会增加得越多。

提高 Alpha 通道的对比度

最初的想法利用了feColorMatrix原始:

<feColorMatrix mode="matrix"
               values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 19 -9"
               result="cutoff" />

这样做的明显缺点是没有人理解这些数字的含义。理论上,存在一个数学上相同的版本,使用feComponentTransfer原始:

<feComponentTransfer result="cutoff">
    <feFuncA type="linear" slope="19" intercept="-9" />
</feComponentTransfer>

它们都使用以下函数转换 RGBA 颜色的 alpha 值

(alpha) => slope * alpha + intercept

并将结果限制在区间 [0, 1] 内,这样

alpha < (0 - intercept) / slope => 0
alpha > (1 - intercept) / slope => 1

有一小部分输入 Alpha 会在输出中转换为部分透明度。 (对于值 19 和 -9,它在 0.46...0.54 之间。)效果是将宽的模糊边界减少为一条非常细的线,现在“柔化”所有角,并在附近的源对象之间具有“粘稠”效果。

但为什么要在输出中留下那条部分透明的细带呢?可以定义完全不透明和完全透明之间的严格区别:

<feComponentTransfer result="cutoff">
  <feFuncA type="discrete" tableValues="0 1" />
</feComponentTransfer>

输入值的范围减半:

alpha <  0.5 => 0
alpha >= 0.5 => 1

这可能会导致明显的抗锯齿伪影。结果的非常小的模糊可能有一个优点:

<feComponentTransfer>
  <feFuncA type="discrete" tableValues="0 1" />
</feComponentTransfer>
<feGaussianBlur stdDeviation="1" result="cutoff" />

叠加原始图形

为了避免对象内部不同颜色的“涂抹”,您可以将原始颜色叠加在“粘性”上。有多种过滤器原语,其中一些带有可以实现此目的的参数。基本叠加可以表示为

<feBlend in="SourceGraphic" in2="cutoff" />
// or
<feMerge>
    <feMergeNode in="cutoff" />
    <feMergeNode in="SourceGraphic" />
</feMerge>
// or
<feComposite operator="over" in="SourceGraphic" in2="cutoff" />

将叠加限制在“goo”区域可以通过以下方式实现

<feComposite operator="atop" in="SourceGraphic" in2="cutoff" />

渲染结果

理论上,除了最后一个区别之外,结果应该看起来是一样的。我设计了一个测试用例,您可以在其中尝试不同的过滤器及其设置。过滤器可以应用于 SVG 圆形和矩形,或 HTML div。您可以比较多色和单色对象的效果。这应该有助于找到具有最佳跨浏览器一致性的过滤器。

const filters = new (function () {
    const fBlur = d3.selectAll('feGaussianBlur:first-child');
    const pBlur = d3.select('feComponentTransfer + feGaussianBlur');
    const fFunc = d3.select('feFuncA[type=linear]');
    const fMatr = d3.select('feColorMatrix');
    let fComp = d3.selectAll('feComposite');
    let active;

    const ids = {
        fcd: '#component-discrete',
        fcl: '#component-linear',
        fmx: '#colormatrix'
    };
    const xmls = new XMLSerializer();
    const pre = d3.select('pre');

    this.activate = function (a) {
        active = ids[a];
        this.showSource();
    };

    this.showSource = function () {
        const source = xmls.serializeToString(d3.select(active).node())
          .replace(/>\s*</g, '><')
          .replace(/<fe/g, '\n<fe')
          .replace(/(<\/\w+>)(<\/\w+>)/g, '$1\n$2')
          .replace(/(<feFuncA|<feMergeNode)/g, '    $1')
          .trim()
        pre.text(source);
    };

    this.blur = function (deviation) {
        fBlur.attr('stdDeviation', deviation);
        this.showSource();
    };

    this.postBlur = function (deviation) {
        pBlur.attr('stdDeviation', deviation);
        this.showSource();
    };

    this.contrast = function (slope, intercept) {
        fFunc.attr('slope', slope)
            .attr('intercept', intercept);
        fMatr.attr('values', [
            "1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0", 
            slope, 
            intercept
        ].join(' '));
        this.showSource();
    };

    this.combinate = function (operator) {
        fComp.remove();
        switch (operator) {
        case 'none':
            return this.showSource();
        case 'merge':
            fComp = d3.selectAll('filter')
                .append('feMerge');
            fComp.append('feMergeNode')
                .attr('in', "cutoff");
            fComp.append('feMergeNode')
                .attr('in', "SourceGraphic");
            return this.showSource();
        case 'blend':
            fComp = d3.selectAll('filter')
                .append('feBlend');
            break;
        default:
            fComp = d3.selectAll('filter')
                .append('feComposite')
                .attr('operator', operator);
            break;
        }
        fComp.attr('in', "SourceGraphic")
            .attr('in2', "cutoff");
        this.showSource();
    };
})();

const tweaks = new (function () {
    this.blur = d3.select('#blur-select');
    const check = d3.select('#blur-select input');
    this.linear = d3.select('#linear-select');
    const selects = d3.selectAll('#linear-select input');
    const slope = selects.filter('#slope');
    const intercept = selects.filter('#intercept');
    const visSlope = d3.select('#visSlope');

    this.activate = function (active) {
        this.blur.classed('inactive', active !== 'fcd');
        check.property('disabled', active !== 'fcd');
        this.linear.classed('inactive', active === 'fcd');
        selects.property('disabled', active === 'fcd');
    };

    this.limit = function () {
        const min = 1 - slope.property('value');
        intercept.attr('min', min);
        if (min > intercept.property('value')) {
            intercept.property('value', min);
        }
        return [
            slope.property('value'), 
            intercept.property('value')
        ];
    };

    this.visualize = function (slope, intercept) {
        visSlope.attr('x1', -intercept * 100 / slope)
            .attr('x2', (1 - intercept) * 100 / slope);
    };
})();

const primitives = d3.selectAll('.primitive');
const examples =  d3.selectAll('.example');
const goo = d3.selectAll('.goo');

d3.selectAll('input[name=variant]').on('change', function () {
    if (!this.checked) return;
    examples.classed('hide', true)
        .filter(this.id).classed('hide', false);
}).dispatch('change');

d3.select('#color').on('change', function () {
    primitives.classed('bw', this.checked);
}).dispatch('change');

d3.select('#filter-select').on('change', function () {
    goo.attr('class', 'goo ' + this.value);
    filters.activate(this.value);
    tweaks.activate(this.value);
}).dispatch('change');

d3.select('#deviation').on('input change', function () {
    d3.select('#devNum').text(this.value);
    filters.blur(this.value);
}).dispatch('change');

tweaks.blur.on('change', function () {
    filters.postBlur(this.checked ? 1 : 0);
}).dispatch('change');

tweaks.linear.on('change', function () {
    const params = tweaks.limit();
    tweaks.visualize.apply(tweaks, params);
    filters.contrast.apply(filters, params);
}).dispatch('change');

d3.select('#combine-select').on('change', function (e) {
  filters.combinate(this.value);
}).dispatch('change');

function tweenFactory (forth) {
    return function () {
        let interpolator;
        const node = this,
            from = forth ? 0 : 500,
            to   = forth ? 500 : 0;
        if (this instanceof SVGElement) {
            interpolator = d3.interpolateTransformSvg(
                'translate(0, ' + from + ')',
                'translate(0, ' + to + ')'
            );
            return function (t) {
                node.setAttribute("transform", interpolator(t));
            };
        } else {
            interpolator = d3.interpolateTransformCss(
                'translate(0px, ' + from + 'px)',
                'translate(0px, ' + to + 'px)'
            );
            return function (t) {
                node.style.transform = interpolator(t);
            };
        }
    };
}

d3.selectAll('.move').transition()
    .on('start', function repeat () {
        d3.active(this)
            .duration(2000)
            .ease(d3.easeSinInOut)
            .tween('forth', tweenFactory(true))
        .transition()
            .duration(2000)
            .ease(d3.easeSinInOut)
            .tween('back', tweenFactory(false))
        .transition()
            .on('start', repeat);
    });
body {
  font-family: sans-serif;
  line-height: 2em;
}
.inactive {
  opacity: 0.5;
}
input[type=number] {
  width: 3em;
}
#vis {
   fill:none;
   stroke:black;
   margin-left:10px;
   vertical-align: middle;
}
pre {
  padding: 10px;
  border: 1px solid black;
  min-height: 10em;
  overflow-x: auto;
  clear: both;
}
.floating {
  float: left;
  margin-right: 30px;
}
.floating.example {
   width: 250px;
   height: 400px;
}
div.goo {
   position: relative;
   width: 500px;
   height: 800px;
   transform: scale(0.5);
   transform-origin: 0% 0%;
}
div.goo div {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 100%;
}
div.goo .move {
  width: 160px;
  height: 160px;
  border-radius: 0;
}
.hide {
  display: none;
}
.bw {
  fill: black;
  background: black !important;
}
.fcd {
  filter: url(#component-discrete);
}
.fcl {
  filter: url(#component-linear);
}
.fmx {
  filter: url(#colormatrix);
}
<script src="https://d3js.org/d3.v4.min.js"></script>

<svg xmlns="http://www.w3.org/2000/svg" class="floating" height="0" width="0">
  <filter id="colormatrix" filterUnits="userSpaceOnUse" x="0" y="0" width="500" height="800">
    <feGaussianBlur stdDeviation="20" />
    <feColorMatrix mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 19 -9" result="cutoff" />
    <feComposite operator="atop" in="SourceGraphic" in2="cutoff" />
  </filter>
  <filter id="component-linear" filterUnits="userSpaceOnUse" x="0" y="0" width="500" height="800">
    <feGaussianBlur stdDeviation="20" />
    <feComponentTransfer result="cutoff">
      <feFuncA type="linear" slope="19" intercept="-9" />
    </feComponentTransfer>
    <feComposite operator="atop" in="SourceG forraphic" in2="cutoff" />
  </filter>
  <filter id="component-discrete" filterUnits="userSpaceOnUse" x="0" y="0" width="500" height="800">
    <feGaussianBlur stdDeviation="20" />
    <feComponentTransfer>
      <feFuncA type="discrete" tableValues="0 1" />
    </feComponentTransfer>
    <feGaussianBlur id="post-blur" stdDeviation="1" result="cutoff" />
    <feComposite operator="atop" in="SourceGraphic" in2="cutoff" />
  </filter>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" class="floating example" viewBox="0 0 500 800">
  <g class="goo fcd">
    <circle class="primitive" r="100" cx="150" cy="400" fill="#ff0000" />
    <circle class="primitive" r="100" cx="350" cy="400" fill="#00ff00" />
    <rect class="primitive move" x="170" y="70" width="160" height="160" fill="#0000ff" />
  </g>
</svg>

<div class="floating example hide">
<div class="goo fcd">
  <div class="primitive" style="background:#ff0000;left:50px;top:300px"></div>
  <div class="primitive" style="background:#00ff00;right:50px;top:300px"></div>
  <div class="primitive move" style="background:#0000ff;left:170px;top:70px"></div>
</div>
</div>

<div id="controls">
  <p>Filtered Objects
  <input name="variant" id="svg" type="radio" checked="checked"></input><label>SVG primitives</label>
  <input name="variant" id="div" type="radio"></input><label>HTML divs</label></p>

  <p><input id="color" type="checkbox"></input>
  <label>Set black and white</label></p>

  <p><label>Blur value</label><br/>
  <input id="deviation" type="range" min="5" max="50" step="5" value="20"></input>
  <span id="devNum">20</span></p>

  <p><label>Cutoff Filter</label><br/>
  <select id="filter-select">
    <option value="fcd" selected="selected">Component/discrete</option>
    <option value="fcl">Component/linear</option>
    <option value="fmx">ColorMatrix</option>
  </select></p>

  <p id="blur-select"><input type="checkbox" checked="checked"></input>
  <label>Post-Blur for discrete</label></p>

  <p id="linear-select"><label>slope</label> <input id="slope" type="number" min="2" step="1" value="19"></input>
  <label>intercept</label> <input id="intercept" type="number" min="-18" max="0" step="1" value="-9"></input> for linear
  <svg id="vis" width="100" height="20">
    <rect x="0.5" y="0.5" width="99" height="19" />
    <line x1="50" y1="20" x2="50" y2="0" style="stroke:red;opacity:0.7" />
    <line id="visSlope" x1="50" y1="20" x2="50" y2="0" />
  </svg></p>

  <p><label>Combining Filter</label><br/>
  <select id="combine-select">
    <option value="atop" selected="selected">Composite atop</option>
    <option value="over">Composite over</option>
    <option value="blend">Blend normal</option>
    <option value="merge">Merge</option>
    <option value="none">none</option>
  </select></p>
</div>

<pre></pre>

相同的外部Codepen https://codepen.io/ccprog/full/jaRGze/.

到目前为止我知道这些渲染错误:

  • Safari、Edge 和 IE 似乎不支持过滤 HTML 对象
  • 当应用于 SVG 对象时,ColorMatrix 在 Chrome 中似乎有问题
  • 据报道,ColorMatrix 和组件/线性在 Firefox 57/Windows 中存在错误

我还没有看到所有这些错误,所以请随意添加到此列表或更​​正它。

相关帖子:SVG feGaussianBlur 和 feColorMatrix 滤镜在 Chrome 中不起作用? https://stackoverflow.com/questions/47219364/svg-fegaussianblur-and-fecolormatrix-filters-not-working-in-chrome

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SVG 粘糊糊的效果在最新版本的 FireFox 上不起作用 的相关文章

  • 有没有基于 WPF 的 Markdown 渲染器? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我们有基于 WPF 的应用程序 我们有单独的字符串存储库 其中的文本在网络中进行编辑 在我们的 WPF
  • 使用 jQuery 更改 CSS 类属性

    有没有办法使用 jQuery 更改 CSS 类的属性 而不是元素属性 这是一个实际的例子 我有一个 div 类red red background red 我想转班级red背景属性 而不是具有类的元素red分配的背景 如果我用 jQuery
  • Highcharts - 使用选定的饼图切片获得 3D 效果

    在 highcharts 中 我试图使当用户选择或将鼠标悬停在饼图的切片上时 该切片会产生沿 z 轴 朝向用户 上升的效果 我试图通过 css 设置阴影过滤器并使切片的边框更宽 填充颜色相同 来实现此目的 然而 我面临的问题是切片仍然可以位
  • jquery UI datepicker仅月份和年份的css定位问题

    我已经实施了这里讨论的解决方案 JQuery 日期时间选择器 只需选择月份和年份 https stackoverflow com questions 4079525 jquery datetime picker need to pick m
  • 如何防止桌面浏览器(Chrome、Safari)缩放网页

    我尝试使用以下元视图端口标记来防止浏览器缩放 但这不起作用 我知道这是可能的 因为我的缩放在此网站上被阻止 未来主义 xyz http futurism xyz 该网站的视口标签是这样的
  • HTML5 视频自动播放功能在 fullpage.js 中不起作用

    我的 HTML5 视频自动播放不起作用
  • 哪种 Javascript 解决方案(不是 .htc)可以真正在 IE7 和 8 中实现抗锯齿圆角?

    哪种 JavaScript 解决方案 不是 htc 确实可以在 IE7 和 8 中实现抗锯齿圆角CSS3在支持的浏览器中给出 我尝试了很多 http www ruzee com blog ruzeeborders http www ruze
  • 如何检测被覆盖的 CSS 属性?

    I can get all css properties for an element with document stylesheets but some of those are not active because those pro
  • 从 Internet Explorer 打印时的默认文件名

    使用 pdf 打印机打印网页 将页面另存为 pdf 时 Chrome 和 Firefox 都使用该页面
  • 使用 html 敏捷包解析 html

    我想从这个 div 中收集所有标签 但不知道如何使用 xpath 方法以最佳方式做到这一点 div class biz info h3 a href profil 78122 s C3 B8rby rehab S rby Rehab a h
  • Bootstrap 标签栏平滑移动导航按钮

    我有一个用于切换块的普通引导选项卡面板 在导航中切换块时 活动选项卡会突出显示 但现在 当我单击活动选项卡的背景时 它会立即发生变化 是否可以使切换选项卡时背景不会立即改变 而是根据需要哪个选项卡而平滑地左右移动 这可以用以下方法完成吗cs
  • 使用 Flot、html、PHP 和 MySql 查询绘制多个图表

    我正在尝试使用 Flot html PHP 和 MySql 查询绘制多个图表 但我陷入了困境 因为我找不到在同一个 html 页面中绘制多个 flot 的方法 为简单起见 在数据库 test db3 映像中包含以下字段 表1 用户名 发送邮
  • 不要包裹 span 元素

    我有一份清单 span 可以在 a 内左右移动的元素 div 元素 如果某些跨度超出了 div 它们应该被隐藏 这可以很好地使用overflow hidden 但是 如果跨度超出了 div 的容纳范围 跨度就会换行 这对于我的用例来说是不期
  • 为什么函数声明在不同浏览器中的处理方式不同?

    虽然我在谷歌中找不到对此的引用 但我熟悉这样一个事实 在 javascript 中 全局函数声明在执行任何代码之前都会被解释 换句话说 这工作得很好 f function f 但是 我注意到 chrome 和 firefox 对全局函数声明
  • 修改 Twitter 帖子上可编辑 Div 的内容

    我正在编写一个 chrome 扩展 它可以帮助用户在 Twitter 上输入内容 当在 twitter 上写推文时 twitter 会打开一个可编辑的 div 容器 当用户输入内容时 twitter 大概正在使用某些网络框架 会生成子 di
  • 哪些 HTML 元素不能包含子节点?

    我一直在寻找一份详尽的清单 但在任何地方都找不到 为了避免必须仔细阅读规范 有谁知道它们是什么 我认为可以包含子元素的补充元素列表也很有用 XHTML 1 和 HTML5 之间的列表有何不同 您可以在以下位置找到 void 元素 不能有任何
  • Safari 滚动条和 SVG

    问题 Safari 无法正常工作 而是使用滚动条渲染我的 SVG 图像 问题的改进版本 如何填充设定的宽度并根据 Safari 中的宽高比计算高度 感谢普罗格兹 相关代码 SVG File viewBox 0 0 800 800 未指定高度
  • 在 Android Chrome 中隐藏 HTML5 音频/视频通知

    我的网络应用程序上有一个 HTML5 音频元素 在某些时候 我使用以下代码以编程方式停止播放 audioElement pause audioElement currentTime 0 播放音频时 我的 Android 设备 使用 Goog
  • 如何对多行文本中的每一行应用填充?

    我已将背景颜色应用于 span 标签 也有左和右padding设置在它上面 问题是 padding仅适用于左侧 开始 和右侧 结束 span 而不是当文本换行时每行的左侧 开始 和右侧 结束 我该如何应用左和右padding to the
  • 将两个数字相加将它们连接起来而不是计算总和

    我将两个数字相加 但没有得到正确的值 例如 做1 2返回 12 而不是 3 我在这段代码中做错了什么 function myFunction var y document getElementById txt1 value var z do

随机推荐