首页 \ 问答 \ 定位由svg屏蔽的多个图像(positioning multiple images that are masked by an svg)

定位由svg屏蔽的多个图像(positioning multiple images that are masked by an svg)

我创建了一个动画,其中2个图像被两个不同的内联svg多边形掩盖。 出现Img1,然后它的多边形<clipPath>动画。 然后出现Img2,然后是其多边形<clipPath>动画。 所有这一切都正常工作,除了图像应该叠加在一起,以便img2最终掩盖img1。 相反,Img2出现在img1下面。

每个图像都在<svg>设置,所以我尝试在自己的<div>设置每个<svg>并将位置设置为绝对。 我还考虑修改<svg> viewbox。 这些都没有奏效。 显然我错过了什么或做错了什么。 有人可以帮忙吗?

是一个解决问题的工作jsfiddle。

这是html:

<body>
    <div id="container">
    <div id="border"></div>
      <!--------masked images-------->
      <div id="img1Masked">
        <svg width="300" height="250" viewbox="0 0 300 250">
          <image xlink:href="https://static.dvidshub.net/media/thumbs/photos/1210/692947/463x486_q75.jpg" x="0" y="0" width="463" height="486" />
        </svg>
      </div>

      <div id="img2Masked">
        <svg width="300" height="250" viewbox="0 0 300 250">
          <image xlink:href="http://edinspace.weebly.com/uploads/5/8/4/4/5844875/3183867_orig.jpg" x="0" y="0" width="933" height="622" />
       </svg>
      </div>
      <!--------polygon clipPaths-------->
      <svg class="svg-defs">
        <defs>
          <clipPath id="clippingImg1">
            <polygon id="img1Shape" points="90 250,302 250,299 -3,138 -3"/>
          </clipPath>
        </defs>
        <defs>
          <clipPath id="clippingImg2">
            <polygon id="img2Shape" points="105 251,301 253,301 -3,66 -3"/>
          </clipPath>
        </defs>
      </svg>
    </div>

    <script src="https://s0.2mdn.net/ads/studio/cached_libs/tweenmax_1.18.0_499ba64a23378545748ff12d372e59e9_min.js"></script>

</body>

而CSS:

#container {
    position:relative;
    width:300px;
    height:250px;
    background-color:#fff;
    overflow:visible;
}
#img1Masked image{
    position:absolute;
    clip-path: url(#clippingImg1);
    opacity:0;
    top:0;
    left:0;
}
#img2Masked image{
    position:absolute;
    clip-path: url(#clippingImg2);
    opacity:0;
    top:0;
    left:0;
}
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
}
#border{ 
    position:absolute; 
    width:298px; 
    height:248px; 
    border:solid 1px #000; 
}

I've created an animation where 2 images are being masked by two different inline svg polygons. Img1 appears, then its polygon <clipPath> animates. Img2 then appears, followed by its polygon <clipPath> animating. All of this is working as it should, except that the images should be stacked on top of each other so that img2 ultimately covers up img1. Img2 instead appears below img1.

Each image is set within an <svg>, so I've tried setting each <svg> within its own <div> and setting the position to absolute. I've also looked into modifying the <svg> viewbox. Neither of these things has worked. Clearly I'm missing something or doing something wrong. Can someone help?

Here is a working jsfiddle that illustrates the problem.

This is the html:

<body>
    <div id="container">
    <div id="border"></div>
      <!--------masked images-------->
      <div id="img1Masked">
        <svg width="300" height="250" viewbox="0 0 300 250">
          <image xlink:href="https://static.dvidshub.net/media/thumbs/photos/1210/692947/463x486_q75.jpg" x="0" y="0" width="463" height="486" />
        </svg>
      </div>

      <div id="img2Masked">
        <svg width="300" height="250" viewbox="0 0 300 250">
          <image xlink:href="http://edinspace.weebly.com/uploads/5/8/4/4/5844875/3183867_orig.jpg" x="0" y="0" width="933" height="622" />
       </svg>
      </div>
      <!--------polygon clipPaths-------->
      <svg class="svg-defs">
        <defs>
          <clipPath id="clippingImg1">
            <polygon id="img1Shape" points="90 250,302 250,299 -3,138 -3"/>
          </clipPath>
        </defs>
        <defs>
          <clipPath id="clippingImg2">
            <polygon id="img2Shape" points="105 251,301 253,301 -3,66 -3"/>
          </clipPath>
        </defs>
      </svg>
    </div>

    <script src="https://s0.2mdn.net/ads/studio/cached_libs/tweenmax_1.18.0_499ba64a23378545748ff12d372e59e9_min.js"></script>

</body>

And the CSS:

#container {
    position:relative;
    width:300px;
    height:250px;
    background-color:#fff;
    overflow:visible;
}
#img1Masked image{
    position:absolute;
    clip-path: url(#clippingImg1);
    opacity:0;
    top:0;
    left:0;
}
#img2Masked image{
    position:absolute;
    clip-path: url(#clippingImg2);
    opacity:0;
    top:0;
    left:0;
}
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
}
#border{ 
    position:absolute; 
    width:298px; 
    height:248px; 
    border:solid 1px #000; 
}

原文:https://stackoverflow.com/questions/34272629
更新时间:2023-02-19 06:02

最满意答案

看起来这是你的主要问题

$berechnung = (60 - $warbeit);

如果你真的想去

//how many hours over 40 hours you have - overtime hours

那应该是

$berechnung = ($warbeit - 40);

你拥有它的方式目前适用于50,但只是巧合,因为60-50 = 50-40。


It looks like this is your main problem

$berechnung = (60 - $warbeit);

If you're really going for

//how many hours over 40 hours you have - overtime hours

Then it should be

$berechnung = ($warbeit - 40);

The way you have it currently works for 50, but only coincidentally, because 60-50 = 50-40.

相关问答

更多
  • 在python中进行比较,不等于需要!= ,而不是<> 。 所以需要: def mape_vectorized_v2(a, b): mask = a != 0 return (np.fabs(a - b)/a)[mask].mean() stats.stackexchange的另一个解决方案: def mean_absolute_percentage_error(y_true, y_pred): y_true, y_pred = np.array(y_true), np.arr ...
  • 您正在使用DateTime对象减去时间戳,因此它尝试将DateTime对象转换为int ,但它不能。 您需要获取DateTime对象的时间戳,以减去两个整数: setTime(00, 00,00); //change time to 00:00:00 $worktime = roun ...
  • 这是add_two_numbers.xml布局 ...
  • 我认为下面的代码就是你所追求的。 诀窍是让你最弱的运算符(+)有一个引用乘法规则的规则,这样才能在乘法匹配之前进行加法,而这在主表达式匹配之后才能发生。 start = any any = additive additive = left:multiplicative "+" right:additive { return left + right; } / multiplicative multiplicative = left:primary "*" rig ...
  • 这段代码可以满足您的需求
  • 那你有很多错误,考虑一下: int a = ([_Price87.text floatValue]); 在右边的大小上你和floatValue - 一个带有小数部分的浮点数,但是在左手大小上你声明a是int - 一个没有任何小数部分的整数。 赋值将截断丢弃小数部分的数字,例如1.82将变为1.这可能不是你想要的。 你的意思是声明一个float ? 但是,让我们看看你的数学和单位 - 根据你给你的领域的名字。 a大概是$ / gal, e是加仑,所以a*e是$(填充油箱的价格)。 让我们将单位放在等式中: ...
  • 你看过System.Linq.Expressions吗? 例如如何将字符串转换为C#中的System.Linq.Expressions.Expression? Have you looked at the System.Linq.Expressions? for example How to convert string into System.Linq.Expressions.Expression in C#?
  • 您需要能够将select中的当前行与相应的输入变量进行匹配。 看看你的另一个问题,我看到你使用typeID作为我认为是你的主键。 考虑到这一点,而不是命名您的输入“veld”我将使用typeID作为数组索引 这样,所有输入都将作为一个名为'product'的数组在php中提交。 然后,您可以使用rows typeID列在产品数组中查找适当的 ...
  • 看起来这是你的主要问题 $berechnung = (60 - $warbeit); 如果你真的想去 //how many hours over 40 hours you have - overtime hours 那应该是 $berechnung = ($warbeit - 40); 你拥有它的方式目前适用于50,但只是巧合,因为60-50 = 50-40。 It looks like this is your main problem $berechnung = (60 - $warbeit); ...
  • 他们的意思是 10 * (1-1) = 0 和 10 * (2-1) = 10 最后,归结为人们从1开始计数(第一页是第1页),但是偏移量从0开始。因此,如果你有一个页码,你需要将它降低一个来获得偏移量number(第一页为1,第一个偏移为0)。 这意味着你首先减去(因此括号),然后乘以。 文字有点令人困惑。 What they mean is 10 * (1-1) = 0 and 10 * (2-1) = 10 In the end this boils down to the fact that ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。