简体   繁体   English

在IE7中如何将文本垂直对齐到固定高度容器中的底部

[英]In IE7 How to vertically align the text to bottom which is in fixed height container

The HTML: HTML:

<div class="testing">
    <div class="a0"><p>Monday, 07 May 2014 00:00 AM</p></div>
    <SPAN class="a1"><SPAN CLASS="b1">abc</SPAN></SPAN>
</div>
<div class="testing">
    <div class="a0"><p>Tuesday, 07 October 2014 00:00 AM</p></div>
    <SPAN class="a1"><SPAN CLASS="b1">abc</SPAN></SPAN>
</div>

The CSS: CSS:

  <style type='text/css'>
  body {
      font: 12px/1.136 arial,verdana,sans-serif;
  }
.testing {
    width: 245px;
    border: 1px solid red;
    background-color: grey;
    height: 25px;
}
.a0 {
    display: inline-block;
    width: 70%;
    float: left;
    background-color:  green;
    vertical-align:bottom;
}
.a1 {
    float: right;
    line-height: 25px;
}
.b1 {
    display: inline-block;
    height: 20px;
    vertical-align: bottom;
}
p {
    margin: 0;
    display: table-cell;
    height: 25px;
    vertical-align: bottom;
}
  </style>

If you see in FF or other browsers, the text in ".a0 p" & ".a1 .b1" is bottom aligned. 如果在FF或其他浏览器中看到,则“ .a0 p”和“ .a1 .b1”中的文本在底部对齐。 Though the content in ".a0 p" is long or short, the text is bottom aligned. 尽管“ .a0 p”中的内容长或短,但文本在底部对齐。

Problem is IE7, I'm not able to bottom align both these contents in both cases. 问题是IE7,在两种情况下我都无法将这两个内容底部对齐。

My restrictions are : 1. ".testing" container has to have fixed height because they will sit beside each other and hence should show equal height 2. The content in right hand side will not change whereas content in left hand side might be shorter (just in one line) or longer (might wrap on next line) 我的限制是:1.“ .testing”容器必须具有固定的高度,因为它们将彼此并排放置,因此应显示相同的高度。2.右侧的内容不会改变,而左侧的内容可能会更短(仅在一行中)或更长(可能在下一行中换行)

Any ideas to fix this alignment issue in IE7 ? 有什么想法可以解决IE7中的对齐问题?

Have you tried changing .a0 (etc.) from display: inline-block; 您是否尝试过从显示中更改.a0(等):inline-block; to display: table;? 显示:表格;?

If this messes up your layout, consider wrapping .a0 in a container with inline-block. 如果这弄乱了您的布局,请考虑将.a0包装在带有内联块的容器中。

The line-height method does not work for IE7. 行高方法不适用于IE7。 See prop up solution in http://css-response.com/alignment/ 请参阅http://css-response.com/alignment/中的支撑解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM