我正在创建一个“圆角”容器,我将用它来定制弹出窗口和工具提示。原来,我用我的圆形png作为角落内容的3x3桌子。Div容器不环绕儿童内容
这些圆角的png是24x24,你可以看到它如何立即强制我的内容的24px页边距。我想将标记转换为Divs以获得更多的边距/填充灵活性。
我真的想在专业外观的顶部24px渐变。我几乎完成了Div容器,但我却遇到了困难!我无法让容器div动态扩展以涵盖子内容!这是我的代码到目前为止。为了清晰起见,我已经删除了背景图片,并用简单的背景色替换了它们。
<div id="container" style="position: absolute; width: 200px; height: 100px;">
<div id="topLeft" style="background-color: Aqua; position: absolute; width: 24px;
height: 24px; top: 0px; left: 0px;">
</div>
<div id="topRight" style="background-color: Aqua; position: absolute; width: 24px;
height: 24px; top: 0px; right: 0px;">
</div>
<div id="bottomLeft" style="background-color: Aqua; position: absolute; width: 24px;
height: 24px; bottom: 0px; left: 0px;">
</div>
<div id="bottomRight" style="background-color: Aqua; position: absolute; width: 24px;
height: 24px; right: 0px; bottom: 0px">
</div>
<div id="topFill" style="background-color: Lime; position: absolute; top: 0px; left: 24px;
right: 24px; height: 24px;">
</div>
<div id="leftFill" style="background-color: Yellow; position: absolute; width: 24px;
left: 0px; bottom: 24px; top: 24px;">
</div>
<div id="bottomFill" style="background-color: Lime; position: absolute; height: 24px;
bottom: 0px; left: 24px; right: 24px;">
</div>
<div id="rightFill" style="background-color: Yellow; position: absolute; width: 24px;
top: 24px; right: 0px; bottom: 24px;">
</div>
<div id="middleFill" style="background-color: Fuchsia; position: absolute; left: 24px;
right: 24px; top: 24px; bottom: 24px;">
</div>
<div id="contentContainer" style="top: 0px; left: 0px; white-space: nowrap; position: absolute;">
ALongStringOFTEXTThatDoesNotBreakToForceTestIfTheDivWillProperlyExpand
</div>
</div>
感谢任何能够让我摆脱困境的人!顺便说一下,这篇文章经过了许多小时的研究并失去了理智。 ;-)
显然你还没有尝试过自己的代码。如果删除宽度和高度值,则包含的div会折叠。溢出:隐藏也不起作用。我更愿意使用表格,因为如果内容大于边界,它将动态扩展超出其宽度值。但(叹气)我会回到我原来的问题。 – RichardB