[英]CSS: Positioning child table using width percentage?
當您訪問頁面內容鏈接時,請使用下面的示例代碼並提交。 您會注意到,子表source_code
並未一直擴展到右側。 如果我在syntax_table
類中添加width: 100%
,它可以解決此問題,但source_code
表會向右對齊,而我不能使其向左移動。
我花了大約2個小時來修復它,現在我需要一些幫助。
這是一些C#示例代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace Test1
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
/// <summary>
/// Calculate method.
/// </summary>
/// <param name="sender">Sender</param>
/// <param name="e">Event Arguments</param>
private void btnCalculate_Click(object sender, RoutedEventArgs e)
{
double weight;
int heightf, heighti;
Double.TryParse(this.txtWeight.Text, out weight);
Int32.TryParse(this.txtHeightF.Text, out heightf);
Int32.TryParse(this.txtHeightI.Text, out heighti);
if (!(heightf >= 1))
MessageBox.Show("A person is at least 1 foot tall.");
else if (!(weight >= 1.0))
MessageBox.Show("A person cannot weigh nothing.");
else if (heightf >= 12)
MessageBox.Show("A person is not taller than 12 feet.");
else
{
double kg = weight * 0.45359237;
int height = heighti + (heightf * 12);
double bmi = weight / (height * height) * 703;
double gbmi = Math.Round(bmi, 1);
this.txtBMI.Text = bmi.ToString("n1");
}
}
}
}
這是因為.syntax_table上的2個表單元格正在自行調整大小,您的瀏覽器將對此進行猜測。 您至少需要設置包含line_numbers的表格單元格的寬度
<table class="syntax_table">
<tr>
<td class="lines"><table class="line_numbers">...</table></td>
<td><table class="source_code">...</table></td>
</tr>
</table>
款式
.source_code { width: 100%; } // add this to give source_code full width of it's cell
.lines { width: 50px } // or set to a percentage, then .code should take up the rest
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.