[英]HTML Element Dynamic Positioning
Im trying to dynamically position html elements based on whether or not certain session variables have been set. 我试图根据是否已设置某些会话变量来动态定位html元素。 My code is as follows:
我的代码如下:
<?php if(!empty($_SESSION['fromARPE'])) : ?>
<script>
document.getElementById("provenance").style.top = "80%";
</script>
<div style="font-size:30px;">Provenance / <br/> Provient de ARPE : </div>
<div style="position:absolute;left:40%;font-size:70px;" id="provenance"><?=$_SESSION['fromARPE']?></div>
<div style="border-bottom:1px solid black; margin-left:35%; width:70%;"></div>';
<?php endif; ?>
Can it be done this way? 可以这样吗? If so, what am i missing?
如果是这样,我想念什么?
Thank you 谢谢
Yes it is fine, you just have to correct some mistakes, see code below: 是的,这很好,您只需要纠正一些错误,请参见下面的代码:
<?php if(!empty($_SESSION['fromARPE'])) { ?>
<div style="font-size:30px;">Provenance / <br/> Provient de ARPE : </div>
<div style="position:absolute;left:40%;font-size:70px;" id="provenance"><?php echo $_SESSION['fromARPE']; ?></div>
<div style="border-bottom:1px solid black; margin-left:35%; width:70%;"></div>';
<script>
document.getElementById("provenance").style.top = "80%";
</script>
<?php } ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.