1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 设置靠近 水平居中的主体内容Div 的 左侧位置固定的Div【HTML】

设置靠近 水平居中的主体内容Div 的 左侧位置固定的Div【HTML】

时间:2024-03-02 20:04:07

相关推荐

设置靠近 水平居中的主体内容Div 的 左侧位置固定的Div【HTML】

web前端|html教程

设置靠近 水平居中的主体内容Div 的 左侧位置固定的Div

web前端-html教程

示例效果:

工商注册 源码,vscode关闭标签前后的,ubuntu配置网段,tomcat 软连接问题,爬虫 网页 ifream,php 手机号码隐藏,广州seo优化在哪里找,获取流量网站源码lzw

1.主体内容的divMain 水平居中;

08影院源码不能用,vscode使用命名空间,ubuntu端口使用,tomcat怎么插入图片,爬虫 文档解析,php 三元操作,崂山区移动seo优化,支付网站源码,flash生日模板lzw

2.divLeft 靠近divMain ,位置固定,不随垂直滚动条而动;

php拼车网站源码,VSCode用的代码编辑器,ubuntu分配单元,tomcat自定义400,r 软件爬虫,php解析xml文档,seo新手怎样做关键词lzw

相关代码:

设置靠近主体内容的左侧固定位置的Div#divLeft{ position:fixed;/* 固定位置 */ top:200px; border:solid 1px #ccc;width:150px; height:500px;} #divMain{width:918px;height:2000px;border:solid 1px #ccc;margin:0 auto;/* 水平居中 */}

左侧固定位置

//动态调整左侧Div的位置 function setDivLeftPosition() { var divMain = document.getElementById("divMain"); document.getElementById("divLeft").style.left = (divMain.offsetLeft - 155) + "px"; } setDivLeftPosition(); // var top, left; // if (div.currentStyle) { left = div.currentStyle.left; top = div.currentStyle.top; } // else if (window.getComputedStyle) { left = window.getComputedStyle(div, null).left; top = window.getComputedStyle(div, null).top; } // alert(left + "," + top);

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。