本文介绍了有越来越得到剃刀,看看我的CSS问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的标签和文本框来排队,我没有得到它工作的权利。

I am trying to get my labels and text boxes to line up and I'm not getting it work right.

下面是我:

AddCustomer.cshtml

AddCustomer.cshtml

@model SuburbanCustPortal.Models.AddCustomerModel

@{
  ViewBag.Title = "Add an Existing Account";
}

<h2>Change Password</h2>
<p>
    Use the form below to add an existing account to your web login.
</p>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm())
{
 @Html.ValidationSummary(true, "Account not found. Please verify the infomartion below and try again.")




  <div>
    <fieldset>
      <legend>Account Information</legend>

      <p>
         <span class="smalllabel">
            @Html.LabelFor(m => m.Branch)
         </span>

         <span class="largelabel">
            @Html.LabelFor(m => m.AccountNumber)
         </span>

      <br />

         <span class="smalltextbox">
            @Html.TextBoxFor(m => m.Branch)
            @Html.ValidationMessageFor(m => m.Branch)
         </span>

         <span class="largetextbox">
            @Html.TextBoxFor(m => m.AccountNumber)
            @Html.ValidationMessageFor(m => m.AccountNumber)
         </span>
      </p>

      <div class="editor-label">
        AND
      </div>

      <div class="editor-label">
        @Html.LabelFor(m => m.LastName)
      </div>
      <div class="editor-field">
        @Html.TextBoxFor(m => m.LastName)
        @Html.ValidationMessageFor(m => m.LastName)
      </div>

      <div class="editor-label">
        OR
      </div>

      <div class="editor-label">
        @Html.LabelFor(m => m.PhoneNumber)
      </div>
      <div class="editor-field">
        @Html.TextBoxFor(m => m.PhoneNumber)
        @Html.ValidationMessageFor(m => m.PhoneNumber)
      </div>


      <p>
        <input type="submit" value="Register" />
      </p>

    </fieldset>
  </div>
}

这是我的site.css:

This is my Site.css:

/*----------------------------------------------------------
The base color for this template is #5c87b2. If you'd like
to use a different color start by replacing all instances of
#5c87b2 with your new color.
----------------------------------------------------------*/
body {
    background-color: #5c87b2;
    font-size: .85em;
    font-family: "Trebuchet MS", Verdana, Helvetica, Sans-Serif;
    margin: 0;
    padding: 0;
    color: #696969;
}

a:link {
    color: #034af3;
    text-decoration: underline;
}

a:visited {
    color: #505abc;
}

a:hover {
    color: #1d60ff;
    text-decoration: none;
}

a:active {
    color: #12eb87;
}

p, ul {
    margin-bottom: 20px;
    line-height: 1.6em;
}

header,
footer,
nav,
section {
    display: block;
}

/* HEADINGS
----------------------------------------------------------*/
h1, h2, h3, h4, h5, h6 {
    font-size: 1.5em;
    color: #000;
}

h1 {
    font-size: 2em;
    padding-bottom: 0;
    margin-bottom: 0;
}

h2 {
    padding: 0 0 10px 0;
}

h3 {
    font-size: 1.2em;
}

h4 {
    font-size: 1.1em;
}

h5, h6 {
    font-size: 1em;
}

/* PRIMARY LAYOUT ELEMENTS
----------------------------------------------------------*/

/* you can specify a greater or lesser percentage for the
page width. Or, you can specify an exact pixel width. */
.page {
    width: 90%;
    margin-left: auto;
    margin-right: auto;
}

header, #header {
    position: relative;
    margin-bottom: 0px;
    color: #000;
    padding: 0;
}

header h1, #header h1 {
    font-weight: bold;
    padding: 5px 0;
    margin: 0;
    color: #fff;
    border: none;
    line-height: 2em;
    font-size: 32px !important;
    text-shadow: 1px 1px 2px #111;
}

#main {
    padding: 30px 30px 15px 30px;
    background-color: #fff;
    border-radius: 4px 0 0 0;
    -webkit-border-radius: 4px 0 0 0;
    -moz-border-radius: 4px 0 0 0;
}

footer,
#footer {
    background-color: #fff;
    color: #999;
    padding: 10px 0;
    text-align: center;
    line-height: normal;
    margin: 0 0 30px 0;
    font-size: .9em;
    border-radius: 0 0 4px 4px;
    -webkit-border-radius: 0 0 4px 4px;
    -moz-border-radius: 0 0 4px 4px;
}

/* TAB MENU
----------------------------------------------------------*/
ul#menu {
    border-bottom: 1px #5C87B2 solid;
    padding: 0 0 2px;
    position: relative;
    margin: 0;
    text-align: right;
}

ul#menu li {
    display: inline;
    list-style: none;
}

ul#menu li#greeting {
    padding: 10px 20px;
    font-weight: bold;
    text-decoration: none;
    line-height: 2.8em;
    color: #fff;
}

ul#menu li a {
    padding: 10px 20px;
    font-weight: bold;
    text-decoration: none;
    line-height: 2.8em;
    background-color: #e8eef4;
    color: #034af3;
    border-radius: 4px 4px 0 0;
    -webkit-border-radius: 4px 4px 0 0;
    -moz-border-radius: 4px 4px 0 0;
}

ul#menu li a:hover {
    background-color: #fff;
    text-decoration: none;
}

ul#menu li a:active {
    background-color: #a6e2a6;
    text-decoration: none;
}

ul#menu li.selected a {
    background-color: #fff;
    color: #000;
}

/* FORM LAYOUT ELEMENTS
----------------------------------------------------------*/

fieldset {
    border: 1px solid #ddd;
    padding: 0 1.4em 1.4em 1.4em;
    margin: 0 0 1.5em 0;
}

legend {
    font-size: 1.2em;
    font-weight: bold;
}

textarea {
    min-height: 75px;
}

input[type="text"],
input[type="password"] {
    border: 1px solid #ccc;
    padding: 2px;
    font-size: 1.2em;
    color: #444;
    width: 200px;
}

select {
    border: 1px solid #ccc;
    padding: 2px;
    font-size: 1.2em;
    color: #444;
}

input[type="submit"] {
    font-size: 1.2em;
    padding: 5px;
}

/* TABLE
----------------------------------------------------------*/

table {
    border: solid 1px #e8eef4;
    border-collapse: collapse;
}

table td {
    padding: 5px;
    border: solid 1px #e8eef4;
}

table th {
    padding: 6px 5px;
    text-align: left;
    background-color: #e8eef4;
    border: solid 1px #e8eef4;
}

/* MISC
----------------------------------------------------------*/
.clear {
    clear: both;
}

.error {
    color: Red;
}

nav,
#menucontainer {
    margin-top: 40px;
}

div#title {
    display: block;
    float: left;
    text-align: left;
}

#logindisplay {
    font-size: 1.1em;
    display: block;
    text-align: right;
    margin: 10px;
    color: White;
}

#logindisplay a:link {
    color: white;
    text-decoration: underline;
}

#logindisplay a:visited {
    color: white;
    text-decoration: underline;
}

#logindisplay a:hover {
    color: white;
    text-decoration: none;
}

/* Styles for validation helpers
-----------------------------------------------------------*/
.field-validation-error {
    color: #ff0000;
}

.field-validation-valid {
    display: none;
}

.input-validation-error {
    border: 1px solid #ff0000;
    background-color: #ffeeee;
}

.validation-summary-errors {
    font-weight: bold;
    color: #ff0000;
}

.validation-summary-valid {
    display: none;
}

/* Styles for editor and display helpers
----------------------------------------------------------*/
.display-label,
.editor-label {
    margin: 1em 0 0 0;
}

.display-field,
.editor-field {
    margin: 0.5em 0 0 0;
}

.text-box {
    width: 30em;
}

.text-box.multi-line {
    height: 6.5em;
}

.tri-state {
    width: 6em;
}

/* custom created by eric */

.smalllabel {
    margin: 1em 0 0 0;
    width: 30em;
}

.smalltextbox {
    margin: 1em 0 0 0;
    width: 30em;
}

.largelabel {
    margin: 1em 0 0 0;
    width: 60em;
}

.largetextbox {
    margin: 1em 0 0 0;
    width: 60em;
}

这是结果:

我试图让科标签和文本框是相同的小尺寸和帐号是大(同)的大小。

I am trying to get the Branch label and text box to be the same small size and the account number to be the larger (same) size.

显然,我不是在code获得css类权。

Apparently I'm not getting the css classes right in the code.

任何想法我做错了吗?

推荐答案

尝试使用 -

@Html.TextBoxFor(m => m.Branch, new { @class = "smalltextbox" })

这将类应用到文本框而不是直接跨度包装 - 我想你使用的是用剃刀页面包含CSS类是适用于您的文本框,而你申请你的CSS到默认的css文件跨度包装。

this will apply the class to the textbox directly and not the span wrapper - I think you are using the default css file with a razor page that contains a css class that is applying to your textbox while you are applying your css to the span wrapper.

此外,smalltextbox和smalllabel看起来是一样的我:) - 不知道,如果你需要他们两个

Also, smalltextbox and smalllabel look the same to me :) - not sure if you need them both.

这篇关于有越来越得到剃刀,看看我的CSS问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:35