css - 三列,中间列带有绝对图标

标签 css html-table icons css-position

我已经完成了三列,其中一个中间列在侧面有一个绝对图标,但是当您在移动设备上显示它或者屏幕与我的不同时,就会出现问题。如果您调整屏幕大小,图标会向左移动。

问题是我为图标使用了绝对位置,没有其他办法吗?

我想得到这个:

link

Codepen Code

 table{
  text-align:center;
  margin-top:20px;
}

td{
  padding: 20px;  
}

#midCol{
  background:lightblue;
  width:90px;
  
}

#iconArrow{
  color:red;
  font-size:100px;
  position: absolute;
  top:140px;
  right:985px;  
}

.col1{
  background:ghostwhite;  
  width:400px;
}

.col2{
  background:ghostwhite;  
    width:400px;
}
   <div class="container">
  <div class="row">
    <table border=0>
      <tr>
        <td class="col1">WORD</td> 
        <td id="midCol" rowspan="6">
          <h2 >C</br>R</br>E</br>A</br>T<span id="iconArrow" class="glyphicon glyphicon-triangle-right"></span></br>I</br>N</br>G</h2>
         </td>
          <td class="col2">SENTENCE</td>
      </tr>
      <tr>
        <td class="col1">WORD</td> 
        <td class="col2">SENTENCE</td>
      </tr>
      <tr>
        <td class="col1">WORD</td>  
        <td class="col2">SENTENCE</td>
      </tr>
      <tr>
        <td class="col1">WORD</td>
        <td class="col2">SENTENCE</td> 
      </tr>
      <tr>
        <td class="col1">WORD</td> 
        <td class="col2">SENTENCE</td> 
      </tr>
      <tr>
        <td class="col1">WORD</td> 
        <td class="col2">SENTENCE</td> 
      </tr>
    </table>
  </div>
</div>

最佳答案

不要在绝对定位元素上设置 leftright 属性,而是使用 auto 将其居中,然后左/右 margin 来插入它。

例如这些设置看起来是正确的:

#iconArrow {
  right: auto;
  margin-left: 6px;
  /* other attributes */
}

关于css - 三列,中间列带有绝对图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42648662/

相关文章:

html - 有没有办法连接 CSS 类选择器?

html - 浏览器什么时候开始支持每个标签的多个类?

css - Bootstrap glyphicon-menu-hamburger 不显示

icons - Sitecore 8 自定义图标,无需使用 zip 文件

css - 如何在网格中隐藏行边框

css - 更改在angularjs中未选中的已选中行的背景颜色

html - 使用 Bootstrap 使 TD 动态适应内容

jquery - 如果没有元素如何选择

HTML colspan 0 替代

android - 在可绘制文件中修改png文件后,它仍然在手机运行中显示旧图标