html - 使用氚 move html 元素

标签 html move moovweb tritium

我正在使用 Moovweb SDK要制作网站的 move 版本,我需要将图像从一个 div move 到另一个。我如何使用氚做到这一点?

<body>
  <div class="kittens">
    <img src="images/husky.jpg" id="husky">
  </div>

  ...

  <div class="puppies">
    [need to move img here]
  </div>
</body>  

最佳答案

有几种方法可以做到这一点。

我觉得最吸引人的方法是使用一些 XPath 轴和 move_here 命令:

$("./body/div[contains(@class,'puppies')]") {
  move_here("ancestor::body/div[contains(@class,'kittens')]/img[@id='huskey']")
}

这种方式使用更少的字符获得相同的效果(但速度较慢):

$("//div[contains(@class,'puppies')]") {
  move_here("//img[@id='huskey']")
}

我喜欢第一种方式的原因是,一般来说,您要查找的 img 不会离 body 太近。您可以执行 //img[@id=''huskey] 而不是执行 ancestor::body ,但这可能会慢得多。使用 ancestor 的另一个好处是它显示了两个元素之间的联系。

关于html - 使用氚 move html 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16175714/

相关文章:

javascript - 水平滚动恢复到原始滚动位置

c++ - 在 std::thread 中使用 std::move

c++ - std::pair assignment with downcast

moovweb - 如何找到使用的moovweb模板?

html-table - 使用氚在 html 中转换表格

html - iOS Web App 启动画面未加载

javascript - 如何更改 HTML 页面中包含特定单词的行的颜色

typekit - 将 Typekit 字体与 moovweb 结合使用

android - 在移动设备中屏幕从纵向 View 旋转到横向 View 时如何停止内容移动?

c++ - 确保 move 构造函数被调用