开发者

HTML Minimum Attributes

开发者 https://www.devze.com 2023-01-31 08:08 出处:网络
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 enoug

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 开发者_StackOverflow中文版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.


In CSS2 compatible browsers you can use min-height: http://www.w3.org/TR/CSS2/visudet.html#min-max-heights

Though for non-compatible browsers (ahem IE6) you'll have to find another way to implement it.

You can see css property compatibility here: http://www.quirksmode.org/css/contents.html


Firstly, you ought to know the following:

  • Content belongs in HTML (Model)
  • Styles belong in CSS (View)
  • Interactions belong in JavaScript (Controller)

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

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;
}

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号