层的位置问题_html/css_WEB-ITnose
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了层的位置问题_html/css_WEB-ITnose,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2326字,纯文字阅读大概需要4分钟。
内容图文
![层的位置问题_html/css_WEB-ITnose](/upload/InfoBanner/zyjiaocheng/407/6ba38ddf28c94c7e8a2a1856b82cbc38.jpg)
JavaScript CSS html
3个span A B C,通过JS设置他的固定位置设置加载和改变大小的时候调用
用的IE9。
页面加载时只能看到样式表的效果,JS没效果。
这样影响排版吗??????????????????????????????
难道刚开始看到是一个样子,调整浏览器大小,在换一种样子吗????????
html
A
B
C
CSS
#A{
background:red;
position:absolute;
display:inline-block;
left: 95%;
}
#B{
background:red;
position:absolute;
display:inline-block;
left:90%;
}
#C{
background:red;
position:absolute;
display:inline-block;
left:85%;
}
JS
function login(){
var A= document.getElementById("A");
A.style.left = (document.documentElement.clientWidth-40)+"px";
var B= document.getElementById("B");
B.style.left = (document.documentElement.clientWidth-80)+"px";
var C= document.getElementById("C");
C.style.left = (document.documentElement.clientWidth-120)+"px";
}
window.onload=login;
window.onresize=login;
个人觉得是页面加载时提示是否启用JS脚本的问题。
求解决
回复讨论(解决方案)
window.onresize最好放到window.onload函数里边。
window.onload=login;
function login(){
var A= document.getElementById("A");
A.style.left = (document.documentElement.clientWidth-40)+"px";
var B= document.getElementById("B");
B.style.left = (document.documentElement.clientWidth-80)+"px";
var C= document.getElementById("C");
C.style.left = (document.documentElement.clientWidth-120)+"px";
window.onresize=login;
}
初步断定,你是不是禁用脚本了
初步断定,你是不是禁用脚本了
这个是正解啊,确实有这东西,我去选项里面设置了,没用
window.onresize最好放到window.onload函数里边。
window.onload=login;
function login(){
var A= document.getElementById("A");
A.style.left = (document.documentElement.clientWidth-40)+"px";
var B= document.getElementById("B");
B.style.left = (document.documentElement.clientWidth-80)+"px";
var C= document.getElementById("C");
C.style.left = (document.documentElement.clientWidth-120)+"px";
window.onresize=login;
}
现在的问题只是初始的时候只有css的效果,并没有login函数的效果。
测试了一遍,写到函数里面不会调用,调用的话也只是加载的时候调用一次
内容总结
以上是互联网集市为您收集整理的层的位置问题_html/css_WEB-ITnose全部内容,希望文章能够帮你解决层的位置问题_html/css_WEB-ITnose所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。