HTML 最小属性 [英] HTML Minimum Attributes

查看:20
本文介绍了HTML 最小属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理内容区域大小根据其中的内容量而变化的页面.这样做的问题是如果这个区域没有足够的内容,它的区域不够大,无法匹配它旁边的侧边栏的高度.我想知道是否有办法分配某种最小高度属性,以便如果没有足够的内容,它只会默认为该高度.这个侧边栏的高度也因页面而异,所以我也想知道是否有办法将它引用到该元素的高度而不是绝对值.

I'm working on pages whose content area's size changes according to the amount of content within it. The problem with this is if there isn't enough content in this area, it's area isn't big enough to match the height of a sidebar that's next to it. I was wondering if there was a way to assign some sort of minimum height property, so that if there isn't enough content, it will just default to that height. This sidebar's height also varies from page to page, so I would also like to know if there's a way to refrence it to the height of that element instead of an absolute value.

推荐答案

首先,你应该知道以下几点:

Firstly, you ought to know the following:

  • 内容属于 HTML(模型)
  • 样式属于 CSS(视图)
  • 交互属于 JavaScript(控制器)

CSS 可以放在 HTML 中的 style 属性中,但除非必要,否则应避免使用.

CSS can be placed within HTML in style attributes, although it should be avoided unless necessary.

CSS 属性 min-height 可以满足您的要求,尽管在 IE6 中不起作用.IE6有一个修复,如下

The CSS property min-height does what you're looking for, although doesn't work in IE6. There is a fix for IE6, it goes as follows

.yourstyle
{
  height: auto !important;
  height: 500px;
  min-height: 500px;
}

确保您的 heightmin-height 值相同.

Make sure your height and min-height values are identical.

这篇关于HTML 最小属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆