我在我的wordpress主题中使用此代码在中心对齐它不起作用,但如果我向右或向左对齐它有效:
<table border="1" align="center">
<tr>
<td>
<div style='width: 435px; height: 90px; background-image: url( http://vortex.accuweather.com/adcbin/netweather_v2/backgrounds/spring1_435x90_bg.jpg ); background-repeat: no-repeat; background-color: #607041;' >
<div id='NetweatherContainer' style='height: 75px;' >
<script src='http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2ex.asp?partner=netweather&tStyle=normal&logo=1&zipcode=MEA|AE|AE005|DUBAI|&lang=eng&size=10&theme=spring1&metric=0&target=_self'></script>
</div>
<div style='text-align: center; font-family: arial, helvetica, verdana, sans-serif; font-size: 10px; line-height: 15px; color: #FDEA11;' >
<a style='color: #FDEA11' href='http://www.accuweather.com/world-index-forecast.asp?partner=netweather&locCode=MEA|AE|AE005|DUBAI|&metric=1' >Forecast</a> | <a style='color: #FDEA11' href='http://www.accuweather.com/maps-satellite.asp' >Maps</a> | <a style='color: #FDEA11' href='http://www.accuweather.com/index-radar.asp?partner=accuweather&zipcode=MEA|AE|AE005|DUBAI|' >Radar</a>
</div>
<img style='float: right; padding-right: 5px;' src='http://vortex.accuweather.com/adc2004/common/images/misc/netweather_v2/adcwhite.png' /><div style='clear: both;' />
</div>
</div>
</td>
答案 0 :(得分:0)
如果要做的只是显示图像,只需将容器放在中心而不是使用table
元素:
.ad {
display: block;
margin: 0 auto;
}
.w435 {
width: 435px;
}
然后给你的div
宽度(你已经拥有):
<div class="ad w435"><!-- content --></div>