CSS:需要一个元素与其相邻元素垂直缩放
也许最好用图像来说明。
- 主要内容填充元素 (d) 左侧的高区域 (b) 需要与该内容元素 (d) 一起缩放,但仍需要其顶部的左上角部分 (a)。
- 还需要有一些元素覆盖两列的底部,如 (c、e) 所示。
- 整个区域的宽度不能超过 640px。
- 文档流程中将有多个这些部分,因此它们不能绝对定位或其他什么。
- 左列 (a,b,c) 是固定宽度,帽片 (a,c,e) 是固定高度。右列可以是固定宽度的,如果这样可以让事情变得更简单的话。
我该怎么做?
Best illustrated with an image, perhaps.
- The tall area (b) to the left of the main content-filled element (d) needs to scale along with that content element (d), but still needs that top-left corner piece (a) at its top.
- There also needs to be elements capping off the bottom of both columns as indicated (c, e).
- The entire area cannot exceed 640px in width.
- There will be more than one of these sections within the flow of the document, so they can't be absolutely positioned or whatever.
- The left column (a,b,c) is a fixed width, and the cap pieces (a,c,e) are fixed heights. The right column can be fixed width, if that makes things simpler.
How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
沿着这些思路的东西可能会实现你想要的;它对各个部分(a、c、e)使用绝对定位,但在可以重复的非绝对定位的 div 内。
“b”部分是使用“.main”div 创建的,因为它将随“.rightColumn”的内容展开。我认为因为其中没有内容,所以您需要用颜色或图像填充它,因此将“b”部分的任何图像等放入“.main”div 的样式中。
HTML
CSS
希望有帮助。
Something along these lines might achieve what you want; it uses absolute positioning for the various pieces (a, c, e) but within a non-absolutely positioned div which you can repeat.
The 'b' section is created using the '.main' div since it'll expand with the content of '.rightColumn'. I assumed as there was no content in there you'd be filling it with a colour or image, so put any image etc. for the 'b' piece in the styling for the '.main' div.
HTML
CSS
Hope that helps.
有时,表格是完成工作的最可行的想法。我认为这种情况存在被批评的风险,因为“表格不应该用于设计/布局”。
其他解决方案将需要(如果针对多个浏览器)大量 javascript 或 CSS3
Sometimes tables area the most feasible idea to get the job done. I would consider this such a situation, risking being bashed since "tables should not be used for design/layout".
Other solutions would require (if targeted across multiple browsers) a lot of javascript or the CSS3 flexible box layout module.