提问者:小点点

当内部有图像时,绝对表宽度不响应


我有以下的设置:一个相关的父表,一个内部有宽度:50%的绝对表和一个位于表单元格内的图像。图像宽度设置为60%。当我在响应模式下测试模板时,当窗口宽度达到大约560px时,表开始占50%以上。当我省略图像时,它需要50%。那个装置有什么问题?

null

.parent{
  width:100%;
  height:120px;
  background:#ff8800;
  position:relative;
}
.child{  
  width:50%;
  height:100%;
  background:#0000ff;
  position:absolute;
  top:0;
  left:0
}
<div class="parent">
  <table class="child">
    <tr>
      <td style="text-align:center">
        <img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" style="width:60%">
      </td>
    </tr>
  </table>
</div>

null


共1个答案

匿名用户

在表上设置max-widthcss属性,它将在两种web浏览器上工作。

.child {
  ...

  max-width: 50%;
}