1

5 列と複数行の html テーブルがあります。最初の列はラベルとその他のテキスト ボックスで構成されます。列の数は、データによって異なる場合があります。

各列の幅は、パーセンテージ (100% を列数で割った値) で均等に割り当てられます。

IE では、ラベル テキストが長い場合、最初の列 (ラベル) が自動的に展開されます。しかし、Chromeでは拡張されていません。

最初の列に適用する必要があるスタイルを教えてください。

以下は、テーブルのサーバー側のコードです。

        TableRow headerRow = new TableRow();
        foreach (string s in columns)
        {
            TableCell cell = new TableCell();
            cell.Width = Unit.Percentage(100.00 / colsCount);
            cell.BorderColor = Color.White;
            cell.BorderStyle = BorderStyle.None;
            System.Web.UI.WebControls.Label tb = new System.Web.UI.WebControls.Label();
            //tb.TextMode = TextBoxMode.MultiLine;
            //tb.Width = Unit.Percentage(100.00);
            //tb.Height = Unit.Pixel(45);


            tb.ID = "TextHeaderBoxRow" + s;
            tb.BackColor = Color.FromArgb(211, 230, 254);
            tb.BorderColor = Color.White;
            tb.BorderStyle = BorderStyle.Solid;
            tb.BorderWidth = Unit.Pixel(0);
            tb.Font.Bold = true;
            tb.Text = s;
            //tb.Attributes.Add("style", "overflow :hidden");
            tb.Font.Name = "Tahoma";
            tb.Font.Size = FontUnit.Point(9);
            //tb.ReadOnly = true;
            tb.TabIndex = -1;

            cell.Controls.Add(tb);
            headerRow.Cells.Add(cell);
        }
        Table1.Rows.Add(headerRow);

        // Now iterate through the table and add your controls 
        for (int i = 0; i < rowsCount; i++)
        {
            TableRow row = new TableRow();
            row.Style.Add(HtmlTextWriterStyle.PaddingRight, "5px");
            row.Width = Unit.Percentage(100.00);

            for (int j = 0; j < colsCount; j++)
            {
                TableCell cell = new TableCell();
                cell.BorderColor = Color.White;
                cell.Width = Unit.Percentage(100.00 / colsCount);
                TextBox tb = new TextBox();
                tb.Width = Unit.Percentage(100.00);
                tb.Font.Name = "Tahoma";
                tb.Font.Size = FontUnit.Point(9);
                tb.Attributes.Add("onchange", "javascript:Changeflag()");
                tb.Attributes.Add("onkeyup", "javascript:Changeflag()");

                // Set a unique ID for each TextBox added
                tb.ID = "TextBoxRow_" + i + "Col_" + j;

                // Add the control to the TableCell
                cell.Controls.Add(tb);
                // Add the TableCell to the TableRow
                row.Cells.Add(cell);
            }
            // Add the TableRow to the Table
            Table1.Rows.Add(row);
        }
4

1 に答える 1

0

Chrome は、あなたが指示したことに従います。すべての幅が等しくなるように指定しているため、ラベルがラップされています。IE はあなたがやりたいことをしていますが、あなたが指示したことはしていません。

最初の列の幅を十分に大きくして折り返しを指定できない場合はwhite-space=nowrap、ラベルのスタイルを追加してみてください。

于 2012-07-16T13:26:40.433 に答える