单行图片文字垂直居中问题——实战

2020-05-10 13:28:35易采站长站整理

使用表格的方法来表现设计效果

<style type="text/css">

<!–

body{

font-size:12px;

font-family:"宋体";

}

table{

border:1px solid #E6EFF8;

margin-bottom:2px;

}

td{

height:23px;

line-height:23px;

padding:0 3px;

}

.name{

font-weight:bold;

}

.money{

font-size:18px;

color:#FFA200;

font-weight:bold;

}

.money strong{

font-size:14px;

}

.renovate{

color:#707070;

}

–>

</style>

<tablewidth="380" cellspacing="0">

<tr>

<tdwidth="80" class="name">遨游旅行网</td>

<tdwidth="157" class="renovate">最后更新:1小时以前 <img src="images/ico/ico_time_bak.gif" alt="time" width="12" height="12" /></td>

<tdwidth="56" class="money">368<strong>元</strong></td>

<tdwidth="77"><img src="images/btn/btn_speak_for.gif" alt="订票" width="61" height="17" /></td>

</tr>

</table>

ie,ff显示效果

在表格中垂直显示是很容易实现的,但接下来用DIV的方法确不那么容易,因为在垂直居中问题DIV总是另人头疼的一个大问题

以下用DIV的方法模拟出上面表格的效果

<style type="text/css">

<!–

.simulate_table {

}

.simulate_table .row {

width:378px;

border:1px solid #E6EFF8;

float:left;

}

.simulate_table .col1, .simulate_table .col2, .simulate_table .col3, .simulate_table .col4 {

float:left;

width:78px;

padding-left:3px;

line-height:23px;

height:23px;

}

.simulate_table .col2 {

width:152px;

}

.simulate_table .col2 img{

}

.simulate_table .col3 {

width:60px;

}

.simulate_table .col4 {

width:77px;

padding-left:0;

}

–>

</style>

<divclass="simulate_table">

<div class="row">

<divclass="col1"><span class="name">遨游旅行网</span></div>

<divclass="col2"><span class="renovate">最后更新:1小时以前 <img src="images/ico/ico_time_bak.gif" alt="time" width="12" height="12" /></span></div>

<divclass="col3"><span class="money">368<strong>元</strong></span></div>