论坛

标题: 能不明白怎么让表格内的文字和图片居中 好晕 [打印本页]

作者: 朱文强jude    时间: 2017-7-26 22:08
标题: 能不明白怎么让表格内的文字和图片居中 好晕
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>使用表格布局百度网及页面属性的设置</title>
<style type="text/css">
body,td,th {
        font-family: "黑体";
        font-size: 14px;
        color: #1F1F1F;
        text-align: right;
}
body {
        margin-left: 0px;
        margin-right: 0px;
        text-align: center;
}
a:hover {
        color: #1203D3;
}
</style>
</head>

<body><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td height="40" align="center" valign="bottom"><a href="http://news.baidu.com" target="_self"><strong>新闻</strong></a> <strong>&nbsp; <a href="https://www.hao123.com/" target="_self">hao123</a>&nbsp; <a href="http://map.baidu.com/" target="_self">地图</a>&nbsp; <a href="http://v.baidu.com" target="_self">视频</a>&nbsp; <a href="https://tieba.baidu.com" target="_self">贴吧</a>&nbsp; <a href="http://xueshu.baidu.com" target="_self">学术</a>&nbsp; <a href="#" target="_self">登录</a>&nbsp; <a href="#" target="_self">设置</a>&nbsp; <a href="#" target="_self">更多产品</a>&nbsp;</strong></td>
    </tr>
    <tr align="center" valign="middle">
      <td height="258" align="center" valign="bottom" style="text-align: center"><img src="images/computer_pc_f9e71b7cee2d086842457387be642f5e.gif" width="269" alt=""/></td>
    </tr>
    <tr>
      <td height="84" align="center" valign="bottom" style="text-align: center"><img src="images/QQ截图20170726221555.png" width="641" height="84" alt=""/></td>
    </tr>
    <tr align="center" style="text-align: center">
      <td height="418" align="center" valign="bottom"><img src="images/QQ截图20170726221704.png" width="67" height="65" alt=""/><br>
      <strong>手机百度</strong></td>
    </tr>
    <tr>
      <td height="80" align="center" valign="bottom"><a href="https://www.baidu.com" target="_self"><strong>把百度设为主页</strong></a><strong>&nbsp; <a href="https://www.baidu.com" target="_self">关于百度</a>&nbsp; About  Baidu&nbsp; 百度推广&nbsp;</strong></td>
    </tr>
    <tr>
      <td align="center" valign="bottom">&nbsp;</td>
    </tr>
    <tr>
      <td align="center" valign="bottom">&nbsp;</td>
    </tr>
  </tbody>
</table>

</body>
</html>
[attach]100324[/attach]



作者: yuanxi52028    时间: 2017-7-27 17:35
同学,你设置了td的全局样式了
[attach]100403[/attach]


把这去掉,然后你td里的独立样式 style="text-align: center" 也没必要写了


这里有个优先级的问题
样式离得越近,优先级越大


为什么设置了align="center",没有用?因为上面设置的td全局样式text-align: right;优先级大于它。
然后为什么你在td里写的独立样式style="text-align: center" 又有用? 因为这里离得最近,他的优先级是最大的。

作者: 夕小七    时间: 2017-8-13 21:51
yuanxi52028 发表于 2017-7-27 17:35
同学,你设置了td的全局样式了

有一点不懂。。既然是这样 ,那为什么上面的图片同样设置却能够居中呢? 不是一样的设置吗?怎么只有手机百度那里受全局样式的影响了。
作者: yuanxi52028    时间: 2017-8-16 09:53
夕小七 发表于 2017-8-13 21:51
有一点不懂。。既然是这样 ,那为什么上面的图片同样设置却能够居中呢? 不是一样的设置吗?怎么只有手机 ...

你上面写的是 style="text-align: center" 下面这个没写
作者: 北辰A    时间: 2017-12-1 22:57
yuanxi52028 发表于 2017-8-16 09:53
你上面写的是 style="text-align: center" 下面这个没写

哈哈哈,我也遇到同样的问题
作者: 北辰A    时间: 2017-12-1 23:04
北辰A 发表于 2017-12-1 22:57
哈哈哈,我也遇到同样的问题

我去掉样式 style="text-align: center"后全都居中了!该如何是好

作者: 北辰A    时间: 2017-12-1 23:10
北辰A 发表于 2017-12-1 23:04
我去掉样式 style="text-align: center"后全都居中了!该如何是好

懂了,去掉以后又点击单元格设置居右对齐哈哈哈




欢迎光临 论坛 (http://bbs.qinxue.com/) Powered by Discuz! X3.1