我有這個頁面上有一個表。它包含一些信息,如用戶名和其他信息。我們允許用戶創建長達255個字符的用戶名。當用戶輸入比表寬度更長的用戶名時,該表將伸出破壞表的樣式。有沒有辦法阻止表格自動調整大小以適應所有內容?另外,是否有強制包裝單個字符串的方法?我真的只是尋找一個快速的內聯CSS修復,我已經嘗試過使用word-wrap:break-word,這是行不通的,也嘗試了style =「table-layout:fixed」,它沒有似乎在爲大小工作。這是我與HTML Word Wrap無法正常工作?
<div id="search_acct">
<h1 class="search-h1">@AdminResource.UserDetails @Model.FirstName @Model.LastName</h1>
@Html.Partial("Message")
<div class="adm_panel_2">
<h4>
@AdminResource.Birthdate</h4>
<ul>
<li>@Convert.ToDateTime(Model.DateOfBirth).ToShortDateString()</li>
</ul>
<h4>
@AdminResource.GlobalAddress</h4>
<ul>
<li>@Model.Address1</li>
<li>@Model.Address2</li>
<li>@Model.City, @Model.StateOrProvince</li>
<li>@Model.PostalCode</li>
</ul>
<h4>
@AdminResource.GlobalCountry</h4>
<ul>
<li>@Model.Country</li>
</ul>
<h4>
@AdminResource.GlobalPhoneNumber</h4>
<ul>
<li>@Html.DisplayFor(m=>m.PhoneNumber)</li>
</ul>
<h4>@AdminResource.GlobalCellNumber</h4>
<ul>
<li>@Html.DisplayFor(m=>m.CellPhone)</li>
</ul>
<h4>
@AdminResource.GlobalEmail</h4>
<ul>
<li>@Model.EmailAddress</li>
</ul>
@if (!string.IsNullOrEmpty(Model.Gender))
{
<h4>
@AdminResource.GenderLabel</h4>
<ul>
<li>@Model.Gender</li>
</ul>
}
@if (AuthorizationHelper.CheckAccess(Resources.User, Operations.ProxyInformation, Model))
{
@Html.Partial("Proxy", Model)
}
</div>
<div class="adm_panel_2">
<table cellspacing="0" cellpadding="0" border="0" class="tbl_user_data" style="table-layout:fixed">
<thead>
<tr>
<th class="hdrcolor" colspan="2">
<h3>Account Information</h3>
</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td class="label-col">
@AdminResource.UserNumber
</td>
<td class="data-col">@Model.UserNumber
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.EmployeeId
</td>
<td class="data-col">
@{
var empId = Model.ProfileAttributes.FirstOrDefault(i => i.ProfileAttribute.Key == "EmployeeID");
if (empId != null)
{
@empId.Value
}
else
{
@Html.Raw("Not Assigned")
}
}
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.UserName
</td>
<td class="data-col" style="word-wrap:break-word">@Model.UserName
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.TestAccount
</td>
<td class="data-col">@if (Model.TestUser)
{
@Html.Raw("Yes")
}
else
{
@Html.Raw("No")
}
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.SendUserName:
</td>
<td class="data-col">
@if ([email protected](AccountStatusValue.InActive) && [email protected](AccountStatusValue.Transit))
{
using (Html.BeginForm("SendUsername", "User", new { userGuid = @Model.UserGuid }))
{
@Html.DropDownListFor(model => model.ApplicationIdentiferForUserNameResend, ApplicationsForUsernameRecovery, new { @class = "narrow" })
<div class="item">
<input type="submit" value="Send User Name" />
</div>
}
}@if ((bool)TempData["sendUsernameSuccess"])
{<img src="@Url.Content("~/Content/img/icon_checkmark.png")" />}
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.GlobalPassword
</td>
<td class="data-col">
@if ([email protected](AccountStatusValue.InActive) && [email protected](AccountStatusValue.Transit))
{
using (Html.BeginForm("ResetPassword", "User", new { userGuid = @Model.UserGuid }))
{
@Html.DropDownListFor(model => model.ApplicationIdentiferForPasswordReset, ApplicationsForPassword, new { @class = "narrow" })
<div class="item">
<input type="submit" value="Reset Password" />
</div>
}
}@if ((bool)TempData["ResetPasswordSuccess"])
{<img src="@Url.Content("~/Content/img/icon_checkmark.png")" />}
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.AccountCreationTime
</td>
<td class="data-col">@Model.CreateDate
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.AccountStatus
</td>
<td class="data-col">@Model.AccountStatus
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.RecentActivationEmailDate
</td>
<td class="data-col">@Model.LastActivationEmailDate.AuditDateTime @Html.ParenIfNotNull(@Model.LastActivationEmailDate.By)<br />
@if ([email protected](AccountStatusValue.InActive) && [email protected](AccountStatusValue.Active))
{@Html.ActionLink("Resend Activation Email", "ResendActivationEmail", new { uniqueUserId = @Model.UserGuid })
}@if ((bool)TempData["ResendActivationEmailSuccess"])
{<img src="@Url.Content("~/Content/img/icon_checkmark.png")" />}
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.UsernameRecoveryDate
</td>
<td class="data-col">
@Model.LastUsernameRecovery.AuditDateTime @Html.ParenIfNotNull(@Model.LastUsernameRecovery.By)
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.PasswordRecoveryDate
</td>
<td class="data-col">
@Model.LastPasswordRecovery.AuditDateTime @Html.ParenIfNotNull(Model.LastPasswordRecovery.By)
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.AccountValidationTime
</td>
<td class="data-col">@Model.ValidationInformationDate
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.AccountValidationStatus
</td>
<td class="data-col">
@if (String.IsNullOrEmpty(@Model.ValidationInformationDate))
{@Html.Raw("Not Validated")}
else
{ @Html.Raw("Validated")
}
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.AccountValidationBy
</td>
<td class="data-col">
@if (!String.IsNullOrEmpty(@Model.ValidationInformationDate))
{
@Model.ValidationInformationValidatedBy;
}
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.GlobalValidationMethod
</td>
<td class="data-col">
@if (ValidationMethodsAllList != null && !String.IsNullOrEmpty(@Model.ValidationInformationDate))
{
SelectListItem validationType = ValidationMethodsAllList.FirstOrDefault(v => v.Value == Model.ValidationInformationValidationTypeID.ToString());
if (validationType != null)
{
@Html.Raw(validationType.Text)
}
}
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.LastLogin
</td>
<td class="data-col">@Model.LastLogin.AuditDateTime
</td>
</tr>
<tr class="odd">
<td class="label-col">
@AdminResource.LastUpdateDate
</td>
<td class="data-col">@Model.LastUpdateDate
</td>
</tr>
<tr class="even">
<td class="label-col">
@AdminResource.UserGuid
</td>
<td class="data-col" style="font-size: 11px">
@Model.UserGuid
</td>
</tr>
</tbody>
</table>
</div>
<div class="clearBoth">
</div>
這是視圖中的一部分工作的HTML,這是一個需要進行調整,以使包裝和不能調整大小並拉伸以適應唯一的部分長用戶名。我試過把「style = table-layout:fixed」放在表格的基本標籤上,但沒有用。
編輯我已經添加了整個視圖來參考頁面的外觀。看起來,加入你們對你所說的地方的暗示並不會做任何事情。我想使用內聯CSS,因此它不會混淆表格其餘部分的樣式。用戶名行是唯一需要某種字詞打包的項目,所以表格不會自動展開以適應用戶名,該用戶名將延伸到我使用的.css文件中設置的像素。
創建一個的jsfiddle以使其更可口 http://jsfiddle.net/b5od73bw/1/ – jbg