CSS width/height pixel and percentage calculation combintaion?

本小妞迷上赌 提交于 2019-12-04 07:05:55
patricjansson

There is a solution in css3, and I also actually think it has been supported in IE for sometime.

Example:

width: -moz-calc(25% - 1em);

See http://hacks.mozilla.org/2010/06/css3-calc/

After search though the net, I realized that it can't be done. The only way to simulate is to adjust it with JavaScript and onresize event.

Not with width itself.

You have to set either the margins and / or the paddings left and right to a total of 50px.

If you want this for the whole page:

body { margin: 0; padding: 25px; }

That will give you a padding at the top and the bottom also. If you don't want that you can set them to zero:

body { margin: 0; padding: 0 25px; }

Note: Most browsers use a default margin for the body, but some (Opera) use a default padding instead, so you should always specify both the margin and padding for the body.

In the second div set

top=50px, 
bottom=0 
position=absolute 

http://jsfiddle.net/4TG2Z/

No javascript needed.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!