0

Here is my first row in table:

<table style="margin:auto; border-color:Black;" border="1">
    <tr style="color:White; background-color:Maroon; height:50%;">
        <td colspan ="2" align="center"><h3>aaa</h3></td>
    </tr>
    <tr>
        <td align="right" style="width:150px;">bbb</td>
        <td style="width:150px;">
            <asp:Label ID="lblKSParterObicna" runat="server" Text="Label"></asp:Label>
        </td>
    </tr>
</table>

Now I wanted to change height for the first row but what ever i set for atribute "height" it is always the same. Does anybody have an idea how to change it?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
daidai
  • 531
  • 5
  • 10
  • 22
  • See [styling first row](http://stackoverflow.com/a/10450263/2654498), and also [setting table row heights](http://stackoverflow.com/a/7530342/2654498) – Nick Aug 14 '13 at 17:14

3 Answers3

0

try it in CSS,

table > tr:first-child td {
height:#px }
Nick
  • 882
  • 2
  • 9
  • 31
0

The reason why it's not working is because you have the tag in your first row. So what I found was: 1. Using percentages for the height won't work (with or without the tag) (not sure why) 2. If you keep the tag in the first row, using a unit like 200px will work as long as the height is bigger than the default height the tag gives. If you remove the tag, any unit in px will work (as long as the font size fits in it).

Here is the jsfiddle for the code below: http://jsfiddle.net/yMKAr/3/

<table style="margin:auto; border-color:Black;" border="1">
    <tr style="color:White; background-color:Maroon; height:200px">
        <td colspan ="2" align="center"><h3>aaa</h3></td>
    </tr>
    <tr>
        <td align="right" style="width:150px;">bbb</td>
        <td style="width:150px;">
            Label
        </td>
    </tr>
</table>
Anna
  • 538
  • 2
  • 4
  • 13
  • And of course, the better option would be creating a css file where you put the formatting - it is easier to keep formatting consistent. – Anna Aug 14 '13 at 17:13
0

Can you check this one. http://jsfiddle.net/DwzA6/

 <div style="height:200px;" >
    <table style="margin:auto; border-color:Black; height:100%;" border="1">
        <tr style="color:White; background-color:Maroon; height: 80%;">
            <td colspan ="2" align="center"><h3>aaa</h3></td>
        </tr>
        <tr>
            <td align="right" style="width:150px;">bbb</td>
            <td style="width:150px;">
                <asp:Label ID="lblKSParterObicna" runat="server" Text="Label"></asp:Label>
            </td>
        </tr>
     </table>
    </div>

In your case you haven't defined the height of table. so thats the reason why you don't see any changes with your first row which is in %. Either keep the height of table in pixel or else create a div of fix height outside table and then set the height of your first row and table in %.

Lakpa Sherpa
  • 126
  • 1
  • 3
  • 14