我的table标签有三个td,我想让第一个td占满一整行,然后让里面的P标签居中显示,应该怎样做呢?其他两个td占了整个table的位置,p标签居中不了
<table style="width: 100%">
<tr>
<td style="text-align: center;">
<p id="head">项目管理软件</p>
</td>
<td style="width: 1%;">
<a href="#searchPage" data-role="button" data-icon="search" data-iconpos="notext" ></a>
</td>
<td style="width: 1%; ">
<a href="#" data-role="button" data-icon="grid" data-iconpos="notext" ></a>
</td>
</tr>
</table>
.
我的天,图片终于出来了,谢天谢地呀
就是里面的文字居中中轴线,我用的是jQuerymobile框架
直接将td 的align属性设置为center不行么
标签 独立的占用一行
<table style="width: 100%">
<tr>
<td style="text-align: center;">
<p id="head">项目管理软件</p>
</td>
<td style="width: 1%;position: relative;">
<a href="#searchPage" data-role="button" data-icon="search" data-iconpos="notext" ></a>
</td>
<td style="width: 1%; position: relative;">
<a href="#" data-role="button" data-icon="grid" data-iconpos="notext" ></a>
</td>
</tr>
</table>
congyeyan9940
项目管理软件 | |
你要的是这个意思吧
</table>
项目管理软件 | |
position:relative;left:30px;
.
应该是右边的搜索和列表图标导致的
<table border="1" style="width:100%">
<tr>
<td style="text-align: center;" colspan="3">
<p id="head">项目管理软件</p>
</td>
</tr>
<tr>
<td style="text-align: center;">
<a href="#searchPage" data-role="button" data-icon="search" data-iconpos="notext" >aa</a>
</td>
<td >
<a href="#searchPage" data-role="button" data-icon="search" data-iconpos="notext" >bb</a>
</td>
<td >
<a href="#" data-role="button" data-icon="grid" data-iconpos="notext" >cc</a>
</td>
</tr>
</table>
.
我想要里面的p文字标签居中中轴线
一个td就行了那两个不要不行?
我想到的是,jQuery mobile一个标签占位30px,直接让p标签也占2个标签的位置,margin-left :60px,和右边的两个标签对称占位,那就居中了
项目管理软件 | |
****** 用tr标签分行,然后第一行占两列,试一下******
<table style="width: 100%" border=1>
<tr>
<td style="text-align: center;">
<p id="head" style="margin-left: 8%">项目管理软件</p>
</td>
<td style="width: 1%;position: relative;">
<a href="#searchPage" data-role="button" data-icon="search" data-iconpos="notext" >123</a>
</td>
<td style="width: 1%; position: relative;">
<a href="#" data-role="button" data-icon="grid" data-iconpos="notext" >456</a>
</td>
</tr>
<tr align="center">
<td colspan="3">|</td>
</tr>
</table>
建议使用div来实现,table布局局限性太大。
align的属性设置为center。
你的这个逻辑是有问题的 ,一个tr就代表了一行,而一个td就代表着一列,你这里的那一个项目管理一个独占一个tr,tr里面有一个td:
你要理解tr和td是什么意思,你才能去做:
代码如下:
项目管理软件 | |
这需要用到jquery么,是不是想太多了,明明css就可以解决的事,表现层的东西尽量不要用行为层去处理,p标签直接css设置一个百分比宽度,margin:0 auto
尽量也不要在标签内加样式,尽量做到分离,便于维护,还有你的text-align:center这个只是文字居中的意思,如果你的p不居中也没用,至于你另外两个td宽度1%是个什么鬼,铺满就直接100%