css - 垂直堆叠多个旋转元素

标签 css rotation transform vertical-alignment

如何在使用旋转时垂直堆叠多个元素,而不必诉诸静态固定元素之间的间距(在我的例子中使用底部的像素宽度)?

这是我当前的 HTML 和 CSS/SASS:

HTML:

<div class="results-indicator-container">
    <div class="results-indicator-label-won">5x</div>
    <div class="results-indicator-label-lost">5x</div>
    <div class="results-indicator-label-tied">5x</div>
</div>

CSS/SASS:

.results-indicator-container {
  bottom: 51px;
  height: 59px;
  left: 167px;
  position: relative;
  width: 16px;
  font-size: 12px;
  float: left;

  .results-indicator-label {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    position: absolute;
    bottom: 0px;
  }

  .results-indicator-label-won {
    @extend .results-indicator-label;
  }

  .results-indicator-label-lost {
    @extend .results-indicator-label;
    bottom: 25px;
  }

  .results-indicator-label-tied {
    @extend .results-indicator-label;
    bottom: 50px;
  }
}

这是我的垂直堆叠元素当前的屏幕截图。

enter image description here

最佳答案

这是一个jsFiddle ,

请告诉我你的想法。

.results-indicator-container {
    height: 59px;
    left: 167px;
    width: 16px;
    font-size: 12px;
    float: left;
}
.results-indicator-label {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
    float:left;
    clear:left;
    height:20px;
    width:20px;
    border-bottom: 1px solid #CCC;
}
.won{

}
.lost{

}
.tied{

}

<div class="results-indicator-container">
    <div class="results-indicator-label won">5x</div>
    <div class="results-indicator-label lost">5x</div>
    <div class="results-indicator-label tied">5x</div>
</div>

关于css - 垂直堆叠多个旋转元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17909831/

相关文章:

python-3.x - 如何使用opencv python在各种彩色背景中找到文档边缘? 【各种背景下的文档扫描】

ruby-on-rails - 如何将 ActiveRecord 属性转换为数据库或从数据库转换?

jQuery 在 div 上方打开一个隐藏的 div

css - IE8 li :hover, 在 li 元素之间的空白处触发悬停?

java - 如何旋转缓冲图像而不裁剪它?有没有办法旋转 JLayeredPane 或 JLabel?

iPhone - 如何将 iPhone 专用应用程序转换为通用应用程序?

html - 如何在没有绝对定位的情况下适应 100% 宽度的元素?

html - 为什么我的 html 页面在独立后无法呈现相同的页面?

c - 将数组向左或向右旋转一定数量的位置,复杂度为 o(n)

jquery - 使用 CSS3 旋转时无法淡出