Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用JS重新定位div_Javascript_Html - Fatal编程技术网

Javascript 使用JS重新定位div

Javascript 使用JS重新定位div,javascript,html,Javascript,Html,有没有一种方法可以使用JS重新定位div,以便在页面的更上层拥有HTML中最相关的副本。但是,当涉及到最终用户所看到的内容时,是否能够灵活地在您喜欢的任何地方显示相同的副本?即 HTML: 这方面有教程吗?我需要使用什么函数?谢谢。在CSS中写下这句话,不需要JS: #three { position: fixed; bottom: 0; } 您可以使用这种javascript来修改CSS属性。为了与名为Safari的用户的想法相同,我们可以提出以下代码: <script

有没有一种方法可以使用JS重新定位div,以便在页面的更上层拥有HTML中最相关的副本。但是,当涉及到最终用户所看到的内容时,是否能够灵活地在您喜欢的任何地方显示相同的副本?即

HTML:


这方面有教程吗?我需要使用什么函数?谢谢。

在CSS中写下这句话,不需要JS:

#three {
    position: fixed;
    bottom: 0;
}

您可以使用这种javascript来修改CSS属性。为了与名为Safari的用户的想法相同,我们可以提出以下代码:

<script>
  document.getElementById('three').style.position = 'fixed';
  document.getElementById('three').style.bottom = 0;
</script>

document.getElementById('three')。style.position='fixed';
document.getElementById('three').style.bottom=0;

出于兴趣,您为什么要这样做?还有,你希望这什么时候发生?点击一个按钮?滑鼠过来?触发因素是什么?我这样做是为了保持网站良好的搜索引擎优化“三”将包含所有网站的原始主页副本,“一”和“二”将包含更便于用户阅读的新副本,但如果它们位于HTML的顶部,会降低网站良好的SEO效果。以下是HTML/CSS,它可能有助于解释我想做的事情-我希望右侧内容顶部的“何必麻烦”框显示在底部的“情景判断”下方。“何必麻烦”已移到最底部。我需要添加什么才能将其保存在容器中?再次感谢。您必须在容器元素中将位置设置为绝对或相对。谢谢。我已设置:.contentCopyHalfBoxHome{position:relative;}。如果这是父节点,它仍然是相同的。这样就行了。我建议你在google chrome webinspector(f12工具)中检查矩阵,我已经尝试将其添加到所有父元素中,以防万一,它仍然无法将其保存在容器中?
#three {
    position: fixed;
    bottom: 0;
}
<script>
  document.getElementById('three').style.position = 'fixed';
  document.getElementById('three').style.bottom = 0;
</script>