简体   繁体   English

表格中从一个单元格到另一个单元格的对齐问题

[英]Alignment Issue from one cell to other in a table

I have an alignment issue where the alignment of the background color of the first cell is little more compared to the other cell. 我有一个对齐问题,其中第一个单元格的背景色与其他单元格的对齐略多。 I don't know why is it happening. 我不知道为什么会这样。

As in the screen shot the cell which has week has the alignment little higher compared to other cell. 如屏幕截图所示,与其他单元格相比,具有星期的单元格的对齐方式更高。 Why is this happening ? 为什么会这样呢?

How am I supposed to make it aligned properly? 我应该如何使其正确对齐? Please help me. 请帮我。

I updated your fiddle and added some background colors to it, as you can see in below html fragment. 我更新了您的小提琴并为其添加了一些背景色,如下面的html片段所示。

<td style="text-align: left; padding-left: 10px;background-color: lime" >
    <div class="ng-binding" ng-class="{'TODAY': 'todayDate'}[event.dayType]">Fri 1.</div>
</td>
<td colspan="7" style="background-color: red">
    <table id="test" style="table-layout: fixed;background-color: aqua">
    <tbody>

I've been trying to reset some of those element's CSS value, though they don't kick in, which makes me believe there is other settings somewhere in your CSS files using the same properties, likely with !important . 我一直在尝试重置那些元素的CSS值,尽管它们不会生效,这使我相信CSS文件中的其他设置使用相同的属性,可能是!important

So, if you check the fiddle you'll see that the recolored td's is different in height and that should narrow down your problem. 因此,如果您检查小提琴,您会发现重新着色的td高度不同,这样可以缩小问题范围。

Now it would be easier for your to check those settings, alter them some, to see how you can give them the same height. 现在,您可以更轻松地检查这些设置,进行一些更改,以了解如何为它们设置相同的高度。

One observation I made is, if you add a text like this <td colspan="7" style="background-color: red"> Test text <table id="test" , you'll see that the red background appear and that background color doesn't have the alignment issue. 我发现,如果添加这样的文本<td colspan="7" style="background-color: red"> Test text <table id="test" ,您会看到红色背景出现,并且该背景色没有对齐问题。

Here is one more fiddle update showing that: https://jsfiddle.net/enypgyt3/4/ 这是另一个小提琴更新,表明: https : //jsfiddle.net/enypgyt3/4/

<p>You should use proper table format like</p>
<p>Table should be proper nested </p>
<p>Table td and tr is not nested properly</p>
<p>Try to comment every table row(tr)</p>
<table border="1" cellspacing="0" cellpadding="5"> <!--table start------->
    <tr>    <!--tr start-->
        <td> 
            <table> 
                <tr>
                    <td>one</td>
                    <td>Two</td>
                    <td>Three</td>
                    <td>four</td>
                </tr>
            </table> <!--/table inside td open and it should properly closed-->
        </td>
        <td>Five</td>
        <td>Six</td>
        <td>Seven</td>
        <td>Eight</td>
    </tr>   <!--/tr end-->

    <tr>    <!--second row statr-->
            <td colspan="4"> <!-- User proper Colspan for every td -->
                One-four five six seven 
            </td>
            <td>
                Eight
            </td>
    </tr>   <!--second row stard-->
    <tr> <!--Third row start-->
            <td colspan="5">
                One-four five six seven eight
            </td>
    </tr>
    <tr>
            <td>One-four</td>
            <td>Five</td>
            <td>Six</td>
            <td>Seven</td>
            <td>Eight</td>
    </tr>
</table> 
<p>If possible try comment maximum tr and td </p>
<p>Follow code indentation</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM