CSS相对定位溢出(压扁div问题)div高度随内容扩展?

发布于 2024-08-11 22:24:54 字数 695 浏览 1 评论 0原文

我正在尝试编辑一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆悲凉 2024-08-18 22:24:54

如果你想制作一个水平居中的div,并用固定的图形作为左边框和右边框,你应该使用如下所示的内容:

html:

<div id="wrapper">
    <div id="content">
        ...your content here...
    </div>
</div>

css:

#wrapper { width:980px; margin:0 auto;)
#content { margin:0 20; background transparen url(background_image.png) top center repeat-y; }

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:

<div id="wrapper">
    <div id="content">
        ...your content here...
    </div>
</div>

css:

#wrapper { width:980px; margin:0 auto;)
#content { margin:0 20; background transparen url(background_image.png) top center repeat-y; }

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文