【发布时间】:2012-11-22 14:40:26
【问题描述】:
我试图将#chat-inner div 保持在#chat-main div 的中间,我可以通过使用百分比值来做到这一点,但我的问题是应该有2px 间隙(关于宽度和高度),百分比值无法提供。为了清楚理解,请参阅 CSS 代码中的注释。
HTML
<div id="chat-outline">
<div id="chat-main">
<div id="chat-inner">
</div>
</div>
</div>
CSS
#chat-outline
{background-color:grey;width:30%;height:40%;
position:fixed;bottom:5px;right:5px;
padding:2px;}
#chat-main
{
width:100%;
height:100%;
background-color:silver;
overflow:hidden;
}
#chat-inner
{
width:95%;
height:97%;
/*How can I give pixels here? I need 2px value*/
margin:2.5% 2.5% 2.5% 2.5%;
/*margin:2px;*/
background-color:cornflowerblue;
}
【问题讨论】: