CSS   发布时间:2022-04-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了css – ie7中位置绝对的问题,div向右移动10px大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在IE7上的位置绝对属性有问题.我的div向右移动了10px.以下是我的代码. IE8和9工作正常.
id菜单是我指的div.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body{margin: 0 0 0 0; padding: 0 0 0 0;}
#holder{width: 400px; height: 500px; margin: 0 auto;}
#left{float: left; width: 50px; height: 500px; BACkground-color: red;}
#center{float: left; width: 300px; height: 500px; BACkground-color: green;}
#right{float: left; width: 50px; height: 500px; BACkground-color: red;}
#header{width: 300px; height: 70px; BACkground-color: yellow;}
#gal-holder{width: 280px; height: 70px; margin: 0 auto;}
#gallery{width: 280px; height: 410px; BACkground-color: orange;}
#button{width: 400px; height: 45px; BACkground-color: red; margin: 0 auto;}
#menu{width: 300px; height: 45px; BACkground-color: pink; position: absolute; z-index: 1000; top: 100px;}
#content{width: 380px; height: 200px; margin: 0 auto; BACkground-color: blue; padding: 10px; color: #fff;}
#clear{height: 10px;}
</style>
</head>
<body>
<div id="holder">
    <div id="left"></div>
    <div id="center">
        <div id="header"></div>
        <div id="menu"></div>
        <div id="gal-holder">
            <div id="clear"></div>
            <div id="gallery"></div>
            <div id="clear"></div>
        </div>
    </div>
    <div id="right"></div>
</div>
<div id="button"></div>
<div id="content">Sample text</div>
</body>
</html>

解决方法

添加位置:相对于#center然后左:0px到#menu.

绝对定位的元素相对于其最接近的父母定位.最好给出你想要定位左/右和上/下坐标的项目,以防止像你找到的那样奇怪的结果.

大佬总结

以上是大佬教程为你收集整理的css – ie7中位置绝对的问题,div向右移动10px全部内容,希望文章能够帮你解决css – ie7中位置绝对的问题,div向右移动10px所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。