【发布时间】:2012-07-13 23:22:21
【问题描述】:
为了找点乐子,我在一个 html5 网站上闲逛。我有一个相对定位的内容包装 div。在里面我有一些元素都是绝对定位的。 出于某种原因,在将我的绝对元素放在最右边时,我得到了一个滚动条。只是想知道是否有人能找出原因!?
<!doctype html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<title>moo</title>
</head>
<body>
<div id="content-wrap">
<div id="card-front" class="absolute">
<img src="/images/business-card-front.png" width="211" height="271" alt="Contact Business Person">
</div>
</div>
</body>
</html>
元素的样式是:
#content-wrap {
width: 960px;
min-height: 1300px;
margin: 0 auto;
position: relative;
background: transparent url(/images/site-bg.png) no-repeat 0 24px;
}
#card-front {
position: absolute;
z-index: 2;
width: 211px;
height: 271px;
top: 225px;
right: -150px;
}
出于某种原因,我不知道为什么这不起作用..违背了绝对的意思?!
感谢您的帮助! 汤姆
【问题讨论】:
标签: css html css-position absolute