admin管理员组文章数量:1393034
I have a little "floating" menu type thing to the left of a profile displaying some info and it looks good, however i used a different pc before and it was overlapping the main page body (due to screen resolution).
So this is the original CSS(with CSS3 fancy stuff stripped out):
position: absolute;
border: 1px solid #73a7f0;
width: 200px;
left:10px;
top: 160px;
padding: 5px 14px;
border-radius: 4px;
and this is what i am trying to do, the line that has changed is:
width: 10%;
Any ideas how it can look the same depending on screens?
Thanks!
I have a little "floating" menu type thing to the left of a profile displaying some info and it looks good, however i used a different pc before and it was overlapping the main page body (due to screen resolution).
So this is the original CSS(with CSS3 fancy stuff stripped out):
position: absolute;
border: 1px solid #73a7f0;
width: 200px;
left:10px;
top: 160px;
padding: 5px 14px;
border-radius: 4px;
and this is what i am trying to do, the line that has changed is:
width: 10%;
Any ideas how it can look the same depending on screens?
Thanks!
Share Improve this question asked Mar 6, 2012 at 16:33 Ian TaylorIan Taylor 1791 gold badge5 silver badges18 bronze badges 1-
What's wrong with
width: 10%;
? – Alexander Pavlov Commented Mar 6, 2012 at 16:35
2 Answers
Reset to default 4Diodeus' answer is true if the container has static positioning. If the container has a width set, even a percentage width, and the container has a position other than static
(the default), the child will use that as the context for its percentage width.
Fiddle here: http://jsfiddle/USJnN/
Absolutely-positioned elements are no longer part of the layout. When a width is specified for a block element, the width is relative to its container. Without a fixed-sized container, a percentage doesn't really have a size context other than the browser window, which is variable.
Using a width in pixels is what you need in this situation.
本文标签: javascriptCSS percentage of screen with positionabsoluteStack Overflow
版权声明:本文标题:javascript - CSS percentage of screen with position:absolute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744654602a2617887.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论