html - 表中的 Div

标签 html css

我有个小问题。这可能很愚蠢,但我无法解决。我有一个表 th,在 th 中我想要一个带有列名称的字符串,然后是这两个箭头来对其进行排序。我试着做 float:left 但它没有反应。现在我的代码如下所示:

        <tr>
          <th >
             <div>
                <div class='columnName'>Column name</div>
                            <div class='arrows'>
                                <div class="arrow-up-icon"></div>
                                <div class="arrow-down-icon"></div>
                            </div>
             </div>
          </th>
        </tr>

这是我的 CSS:

.arrow-up-icon {
  background-image: url('here url code');
  background-size: contain;
  background-repeat: no-repeat;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  width: 20px;
  float: left;
  cursor: pointer;
  border:1px solid red;
}

.arrow-down-icon {
  background-image: url('');
  background-size: contain;
  background-repeat: no-repeat;
  top: 50%;
  transform: translateY(-50%);
  height: 20px;
  width: 20px;
  float: left;
  cursor: pointer;
  border:1px solid black;
}

.columnName {
  float: left;
 }

.arrows {
  float: left;
 }

最佳答案

.arrow-up-icon {
  cursor: pointer;
  float: left;
}

.arrow-up-icon:before {
  content: '↑';
}

.arrow-down-icon {
  cursor: pointer;
  float: right;
}

.arrow-down-icon:before {
  content:'↓';
}

.columnName, .arrows {
  display: inline;
  float: left;
 }
        <table>
        
        <tr>
          <th >
             <div>
                <div class='columnName'>Column name</div>
                            <div class='arrows'>
                                <div class="arrow-up-icon"></div>
                                <div class="arrow-down-icon"></div>
                            </div>
             </div>
          </th>
        </tr>
        </table>

关于html - 表中的 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47035852/

相关文章:

html - 为什么 <a> 标签与不可点击区域重叠?

javascript - 保持音频和视频同步 HTML5

css - 将内容放在 div 中

jquery - 在响应式插件上使用 CSS 调整包装器大小

html - 可扩展的 div(点击时),内联 block ,不下推第二行的其他 div

php - MYSQL数据限制数

javascript - 禁用下拉菜单直到页面加载 - Javascript

html - flex 的预期生命周期长吗

css - 在 Polymer 中使用 CSS Mixins

javascript - 将 P5 草图作为截面背景