该设计
信息小部件内容应在中间垂直对齐,如下所示:
编码设计
视窗:Chrome 20 / FF 14 / IE 9
Mac(狮子 / 狮子山):Chrome / FF
编码
HTML
<div class="info">
<div class="weather display clearfix">
<div class="icon"><img src="imgs/icons/thunderstorms.png" align="Thunderstorms" /></div>
<div class="fl">
<p class="temperature">82° / 89°</p>
<p class="conditions">Thunderstorms</p>
</div>
</div>
<div class="time display">
<p>11:59 <span>AM</span></p>
</div>
<div class="date display clearfix">
<p class="number fl">23</p>
<p class="month-day fl">Jun <br />Sat</p>
</div>
</div><!-- //.info -->
CSS
.info {
display:table;
border-spacing:20px 0;
margin-right:-20px;
padding:6px 0 0;
}
.display {
background-color:rgba(255, 255, 255, .2);
border-radius:10px;
-ms-border-radius:10px;
color:#fff;
font-family:"Cutive", Arial, sans-serif;
display:table-cell;
height:70px;
vertical-align:middle;
padding:3px 15px 0;
}
.display p {padding:0;line-height:1em;}
.time, .date {padding-top:5px;}
.time p, .date .number {font-size:35px;}
.time span, .display .month-day, .conditions {
font-size:14px;
text-transform:uppercase;
font-family:"Maven Pro", Arial, sans-serif;
line-height:1.15em;
font-weight:500;
}
.display .month-day {padding-left:5px;}
.icon {float:left;padding:0 12px 0 0}
.display .temperature {font-size:24px;padding:4px 0 0;}
.display .conditions {text-transform:none;padding:2px 0 0;}
.lt-ie9 .display { /* IE rgba Fallback */
background:transparent;
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#20ffffff,endColorstr=#20ffffff);
zoom:1;
}
问题
查看上面的编码设计图像,您可以看到它是如何摆脱对齐的。进一步查看后,文本正在 mac 上的元素之外呈现。
视窗
苹果电脑
笔记
我通过 Google Web Fonts 样式表嵌入字体。
经过测试
我尝试了以下方法:
- 在每个元素上设置行高。
- 在每个元素上设置字体权重。
- 在每个元素上设置高度。
- 每个元素上的高度/填充顶部的组合。
- 使用百分比/em/px 进行填充。
It seems that no matter what I try, the content will never center align perfectly across mac and pc.
My Question(s)
It is possible to achieve what I'm trying to do in a simplistic manner?
Should I forgo the display:table-cell;
route and set specific heights/paddings on each element and child? I will still run into padding/spacing issues between the two OS's.
What should I categorize this issue under? Line-height? Table-cells? OS? etc...
Thanks in advance!