高度自动计算的高度不正确,所以背景不工作

编程入门 行业动态 更新时间:2024-10-25 20:28:28
本文介绍了高度自动计算的高度不正确,所以背景不工作 - ASP 4.0 - 使用的主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想让自动高度。

我使用的是母版页,asp 4.0,css

这里的配置

p>

这里的css类

* { margin:0; padding:0; } .logo { height:100px; width:1000px; position:absolute; top:0px; } body,html { height:auto; height:100%; } .footer { visibility:hidden; } .MenuBarMasterPage { position:absolute; top:202px; margin-left:auto; margin-right:auto; width:1000px; height:40px; } body { background:#0C0C0C url(static.monstermmorpg/images/backgrounds/animus-mix.gif)repeat ; margin-right:auto; margin-left:auto; width:1000px; background-position:top center; } .main { position:absolute; top:242px; width:1000px; background:#D1D1D1 url(static.monstermmorpg/images/backgrounds/content.png)repeat; z-index:2; height:auto; }

根据firebug,main的计算风格高度为0px是问题

解决方案

为了避免必须在每个页面上手动设置不同的固定高度解决方案),您有两个选项:

  • 使用JavaScript计算高度。
  • t使用绝对定位。

没有理由对布局使用绝对定位。你应该从几乎所有的东西中删除 position:absolute ,并写下新的CSS。

你需要一个批次 float:left 和 float:right 。

I am trying to make height auto. Whatever i tried did not work until now.

I am using masterpage, asp 4.0 ,css

Here the config

Here the css classes

* { margin: 0; padding: 0; } .logo { height: 100px; width: 1000px; position: absolute; top: 0px; } body, html { height: auto; height: 100%; } .footer { visibility: hidden; } .MenuBarMasterPage { position: absolute; top: 202px; margin-left: auto; margin-right: auto; width: 1000px; height: 40px; } body { background: #0C0C0C url(static.monstermmorpg/images/backgrounds/animus-mix.gif) repeat; margin-right: auto; margin-left: auto; width: 1000px; background-position: top center; } .main { position: absolute; top: 242px; width: 1000px; background: #D1D1D1 url(static.monstermmorpg/images/backgrounds/content.png) repeat; z-index: 2; height: auto; }

According to the firebug the computed style height of main is 0px this is the problem

解决方案

To avoid having to manually set a different fixed height on each page (which is a terrible solution), you have two options:

  • Use JavaScript to calculate the height.
  • Don't use absolute positioning.

There is no reason to use absolute positioning for your layout. You should remove position: absolute from almost everything, and write new CSS.

You're going to need a lot of float: left and float: right.

更多推荐

高度自动计算的高度不正确,所以背景不工作

本文发布于:2023-11-12 09:37:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581135.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:高度   不正确   背景   工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!