html - 将两列对 Angular 线合并为具有不同颜色背景的一列

标签 html css css-tables

我目前正在构建一个 HTML/CSS 表格,根据一些基本逻辑,该表格显示每个单元格的值和颜色,颜色为红色/黄色/绿色或灰色/白色。

现在的问题是,有些列需要合并 - 包括它们的不同颜色被对 Angular 线分割,即像这样:

enter image description here

虽然我可以轻松地为正常细胞着色,但我仍在为 split 细胞寻找一种优雅的解决方案。到目前为止我唯一的想法是为每种颜色组合使用背景图片。但是,我想知道是否有更好的原生 CSS 解决方案?

最佳答案

你可以用伪元素和 css 三 Angular 形来做到这一点。

像这样:

FIDDLE

标记

<div class="cell">
    <div class="top">50%</div>
    <div class="bottom">40%</div>
</div>

CSS

.cell
{
    width: 100px;
    height:40px;
    color: white;
    position: relative;
    line-height: 20px;
}
.bottom
{
    text-align: right;
}
.cell div:before
{
    content: '';
    display: inline-block;
    position: absolute;
    width: 0px;
    height: 0px;
    border-style: solid; 
    z-index: -1;
}
.top:before
{ 

    border-width: 40px 100px 0 0;
    border-color: green transparent transparent transparent;
}
.bottom:before
{
    border-width: 0 0 40px 100px;
    border-color: transparent transparent red transparent;
    top:1px;
    left:1px;
}

关于html - 将两列对 Angular 线合并为具有不同颜色背景的一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17084292/

相关文章:

javascript - Bootstrap 导航 - 手机

css - Webpack 4 Production Build 不加载图像和 CSS

css - 2 div 在除 IE6 之外的所有系统中都水平排列?怎么解决?

html - 如何删除 div 表格单元格中的垂直填充?

javascript - 如何在 CSS 的可调整大小的空间中排列不同长度的元素?

c# - 在jquery中设置对话框文本

javascript - 选择选项的选定属性不会自动更新

html - Twitter Bootstrap 基础 CSS

javascript - 在 setInterval AJAX 之间保留 jQuery 生成的标记

css - 显示 :table for IE7?