【问题标题】:Dynamic resizing via Javascript in WordPress在 WordPress 中通过 Javascript 动态调整大小
【发布时间】:2015-11-01 22:51:03
【问题描述】:

我在 WordPress 中有一个非常简单的页面,它在 WordPress 框架之外可以正常工作,但是一旦我将它集成到 WordPress 主题中,它就拒绝重新调整元素的大小。函数的其余部分执行正常,但忽略调整大小。

让 Javascript 在 WordPress 主题中工作有什么特别之处吗?

function play_vid(vid,xSrc,xWidth,xHeight,xTitle){
  var myVideo = document.getElementById(vid); 
    myVideo.src=xSrc;
    myVideo.style.width=xWidth;
    myVideo.style.height=xHeight;

  var myVideoPlate = document.getElementById('video_plate'); 
  myVideoPlate.style.width=xWidth+40;
  myVideoPlate.style.height=xHeight+60;

  var myVideoTitle = document.getElementById('video_title'); 
  myVideoTitle.innerHTML=xTitle;
  myVideoTitle.style.height=xHeight+60;


    var myElement = document.getElementById("video_plane"); 
    myElement.style.minHeight="100%";
    myElement.style.visibility="visible";
  document.body.style.overflow="hidden";
  myVideo.play(); 
}

【问题讨论】:

    标签: javascript css wordpress


    【解决方案1】:

    样式属性必须是有效的 css 字符串,这意味着您不能只使用数字,还必须添加测量值,而您缺少 @height 和 @width。 只需添加 +"px"

    myVideoTitle.style.height=(xHeight+60)+"px";
    

    【讨论】:

    • 这太奇怪了,它可以在静态 HTML 页面上运行。谢谢!
    猜你喜欢
    • 2015-04-03
    • 2013-07-04
    • 2016-07-05
    • 1970-01-01
    • 2012-09-03
    • 2020-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多