html - 如何CSS两个垂直圆柱体

标签 html css

我想做这个

CSS Cylinders

如何使用 CSS 实现这些?

更新

如何在同一底部对齐圆柱体,以及如何在它们下方添加标题?

最佳答案

您必须将圆柱体图像分成三部分:顶部、中间(将重复)和底部。像这样:

例如,将它们命名为 top.png、middle.png 和 bottom.png。

然后您需要三个 HTML 元素,每个部分一个:

<div class="cylinder top"></div>
<div class="cylinder middle" style="height:300px"></div>
<div class="cylinder bottom"></div>

还有CSS:

.cylinder {
    width: <width of the cylinder image>px;
}
.cylinder.top {
    background-image:url('top.png') no-repeat;
    height: <height of the top image>px;
}
.cylinder.middle {
    background-image:url('middle.png') repeat-y; /* repeat vertically */
}
.cylinder.bottom {
    background-image:url('bottom.png') no-repeat;
    height: <height of the bottom image>px;
}

要更改高度或圆柱体,您只需修改中间元素上的 the style="height:300px"

此解决方案适用于任何浏览器,甚至是 IE6。

关于html - 如何CSS两个垂直圆柱体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4792492/

相关文章:

css - 如何使图像位于另一层之后

html - 从 div 中删除所有填充

javascript - 使用 Stellar.js 时,绝对定位元素在 FireFox 中定位不正确

javascript - 检测窗口大小 onload 以及调整大小?

html - 在虚线跨度上工作,我不知道如何使它成为同一条线

jquery - 悬停时增加和减少列表中 block 的宽度和高度

html - 不规则的图像和字体大小 - 移动

html - div 底部不需要的填充

php - 我如何才能 100% 确定 HTML 标签内的 JS?

html - 在 Bootstrap 网格中没有获得任何 margin