【问题标题】:HTML Table with curved linked heading [closed]带有弯曲链接标题的 HTML 表格 [关闭]
【发布时间】:2017-12-04 09:27:31
【问题描述】:

我正在尝试实现这种类型的表格,以便我可以为列添加扩展标签。但我什至不知道在搜索中尝试和描述它的名称。

编辑 我可以找到如何使用 CSS 圆化 html 边框。但这无助于将行链接到列。我可以旋转列标题文本,但同样,这不是我想要的。

我能想到的最接近的方法是带有边框或背景颜色以突出连接的完整表格,但这将是方形而不是圆形。

我想知道是否有使用 css 实现此目的的方法。或者一个可以做同样事情的库。

【问题讨论】:

    标签: javascript jquery html css web


    【解决方案1】:

    我从来没有听说过这样的事情。一般来说,你不能像这样弯曲任何元素,假设链接是表格的正常部分 (tr/td)。

    我在这里创建了一些小东西,制作曲线,你可以将它添加到你的桌子上以产生这种感觉,但请注意,你不能在里面写字,最重要的是,它不起作用,因为这会跨浏览器和缩放看起来不精确(在另一个项目上测试,我还需要一些带圆圈的东西)

    所以你应该以其他方式更好地设计你的桌子。

    无论如何,这是一个带有圆形链接的sn-p

    .circ, .circ2, .circ3 {
      position:absolute;
      
      border-radius: 50%;
      
      display: inline-block;
      background-color: transparent;
      border-top: 1px solid black;
      border-left: 1px solid transparent;
      border-right: 1px solid transparent;
      border-bottom: 1px solid transparent;
      transform: rotate(45deg);
    }
    
    .circ{width: 180px;
      height: 180px; top:0; left:0;}
      .circ2{width: 135px;
      height: 135px; top:23px; left:22px}
      .circ3{width: 80px;
      height: 80px;  top:50px; left:50px;}
      
      .container{position:absolute; top:20px; left:20px; border:1px dotted black;width:200px; height:200px;}
    <div class="container">
    
    <div class="circ"></div>
    <div class="circ2"></div>
    <div class="circ3"></div>
    </div>

    Als 已阅读此内容 - 这是浏览器支持的完整转换列表: https://www.w3schools.com/cssref/css3_pr_transform.asp

    【讨论】:

    • 看起来不错,但是如何将其与表格和单元格对齐?
    • 这正是我所说的......这需要大量的定位工作,你必须首先制作曲线,所以你必须找到正确的尺寸和定位。然后你把曲线所在的整个 div 放在你的桌子上……但正如我所说,这些是边框,它们在浏览器中的绘制方式不同,所以你可能永远不会在任何地方都得到好的结果。此外,如果您缩放页面,则很容易变得混乱。所以我的建议和帖子一样。以不同的方式设计您的餐桌。
    • 太好了,这几乎回答了这个问题。谢谢。
    【解决方案2】:

    这是一个与您正在寻找的东西非常接近的模型

    https://codepen.io/anon/pen/dZrXPd

    我用 SCSS 写了一部分,因为它对我来说更容易,这里的 sn-p 是它的编译版本...

    ul {
      list-style: none;
      padding: 0;
      width: 400px;
      float: left;
    }
    ul li:nth-child(1) {
      background-color: blue;
    }
    ul li:nth-child(2) {
      background-color: green;
    }
    ul li:nth-child(3) {
      background-color: red;
    }
    
    .clearfix:after {
      display: block;
      content: "";
      clear: both;
    }
    
    .round-edges {
      float: left;
      width: 80px;
      background-color: grey;
      height: 70px;
      margin-top: 15px;
      border-radius: 0 50px 0 0;
      position: relative;
    }
    .round-edges .round1 {
      background-color: blue;
      height: 70px;
      width: 75px;
      border-radius: 0 50px 0 0;
    }
    .round-edges .round2 {
      background-color: green;
      height: 50px;
      width: 50px;
      position: absolute;
      bottom: 0;
      left: 0;
      border-radius: 0 25px 0 0;
    }
    .round-edges .round3 {
      background-color: red;
      height: 33px;
      width: 25px;
      position: absolute;
      bottom: 0;
      left: 0;
      border-radius: 0 20px 0 0;
    }
    
    tr td:nth-child(1) {
      width: 400px;
    }
    
    tr td:nth-child(2) {
      background-color: red;
      width: 20px;
      text-align: center;
    }
    
    tr td:nth-child(3) {
      background-color: green;
      width: 20px;
      text-align: center;
    }
    
    tr td:nth-child(4) {
      background-color: blue;
      width: 20px;
      text-align: center;
    }
    <div class="clearfix">
      <ul>
        <li>
          Last Col
        </li>
        <li>
          Middle Col
        </li>
        <li>
          First col
        </li>
      </ul>
      <div class="round-edges">
        <div class="round1"></div>
        <div class="round2"></div>
        <div class="round3"></div>
      </div>
    </div>
    <table>
      <tr>
        <td>
          Something
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>    
      </tr>
      <tr>
        <td>
          Some other thing
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>    
      </tr>
      <tr>
        <td>
          Something Completely Different
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>    
      </tr>
      <tr>
        <td>
          Foo
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>
        <td>
          X
        </td>    
      </tr>
    </table>

    【讨论】:

    • 花时间检查代码并投反对票 - 但没有花时间写答案有什么问题?
    【解决方案3】:

    ???使用 id 或数字 + 图例 #1 #2 #3 left mid right L M R 或者,如果您创建图像,可能会更好。

    但是,您仍然可以在表格行中使用边框半径 + 位置。如您所愿,它可能无法跨浏览器工作。
    http://border-radius.com
    (以现场黑色输入框写40为例)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-05
      • 2019-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多