CSS相对定位溢出(压扁div问题)div高度随内容扩展?
我正在尝试编辑一些 css 以在我的网站的右侧和左侧包含边框。我的问题是,当我将高度设置为 100% 或自动时,什么也不会发生,但是当我更改高度时,它可以工作,但我无法使用它,因为我希望它随内容而变化。
我注意到在表达式网络中,我的 sitegrinder div 看起来太挤在顶部而不是内容的完整长度。这可能是因为定位的原因吗?溢出可以以某种方式解决这个问题吗?
我已经包含了下面的 css 和 html,
<div id="sitegrinder">
<div id="bgrepeat">
<div id="id68logo"></div>
<div id="bglight"></div>
<div id="topbanner"></div>
<div id="id53light"></div>
#sitegrinder {
left: auto;
top:auto;
width: 960px;
position: relative;
margin:auto; }
我还注意到,当我在 css 中包含溢出:隐藏时,我的所有内容都显示在该 div 的顶部。
I'm trying to edit some css to include a border to the right and the left of my site. My problem is that when I make my height 100% or auto nothing happens, but when I change the height it works, but I can't use this as I want it to change with the content.
I've noticed in expression web my sitegrinder div looks too squashed up the top instead of the full length of the content. Could this be due to positioning? Could overflow fix this somehow?
I have included the css and html below
<div id="sitegrinder">
<div id="bgrepeat">
<div id="id68logo"></div>
<div id="bglight"></div>
<div id="topbanner"></div>
<div id="id53light"></div>
#sitegrinder {
left: auto;
top:auto;
width: 960px;
position: relative;
margin:auto; }
I've also noticed that when I include overflow:hidden within the css all my content appears squashed at the top within this div.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想制作一个水平居中的div,并用固定的图形作为左边框和右边框,你应该使用如下所示的内容:
html:
css:
background_image.png 应该是宽度为 980px 的图像。最左边的 10 个像素..和最右边的 10 个像素是你的边框,你可以按照你想要的方式设置样式。
if you want to make a horizontally centered div with a fixed with and graphics as left and right borders you should use something like this:
html:
css:
The background_image.png should be an image with 980px width. The 10 leftmost pixel.. and the 10 rightmost pixel are your border u can style the way you want.