【问题标题】:column and row layout using CSS3使用 CSS3 的列和行布局
【发布时间】:2017-08-21 10:24:30
【问题描述】:

我正在尝试使用引导程序实现列样式。我想在一列中标记和字段值。理想情况下查找 5 列,每列将包含标签和字段值。我已经注释掉了一些标签和字段,因为我非常接近但仍然没有得到它。我还附上了我的代码的输出。有人可以告诉我哪里出错了。

css

<style>
.requestDetail {
    font-size: 9px;
    font-family: Helvetica, sans-serif, sans-serif;
  }


</style>


<div class="requestDetail">
    <div class="row">
        <div>@Html.Label("Country Number", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">GB</div>
        <div>@Html.Label("Company Code", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1">8100</div>
        <div>@Html.Label("Project Name", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">Nishan ProjectName</div>
        <div>@Html.Label("Name Of Responsible Person", htmlAttributes: new { @class = "editor-label col-sm-2" })</div><div class="col-sm-1 editor-field">Desmond Beckford</div>
        @*<div>@Html.Label("Modified By", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">Nishan Murugdfdd</div>*@
    </div>
    <div class="row">
        <div>@Html.Label("Customer Number", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">0081000653</div>
        <div>@Html.Label("Customer Shortname", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">AMEY</div>
        <div>@Html.Label("Project Content", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">ProjectContent</div>
        @*<div>@Html.Label("Applicant Number", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">00000372</div>*@
    </div>
    <div class="row">
        <div>@Html.Label("Sales Office Code", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">8101</div>
        <div>@Html.Label("Sales Office", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">Hatfield PS</div>
        <div>@Html.Label("Contract Start Date", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">20/03/2017 17:04:36 +00:00</div>
        @*<div>@Html.Label("Applicant Name", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">fgfgfgfgfgf</div>*@
    </div>
    <div class="row">
        <div>@Html.Label("Name", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">DNU - Amey Group Information Servic</div>
        <div>@Html.Label("Status", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">New Request</div>
        <div>@Html.Label("Contract Duration In Months", htmlAttributes: new { @class = "editor-label col-sm-2" })</div><div class="col-sm-2 editor-field">5</div>
        @*<div>@Html.Label("Is Required To Send To Cost Desk", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">@(Model.IsRequiredToSendToCostDesk)</div>*@
    </div>
    <div class="row">
        <div>@Html.Label("City", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">BELFAST</div>
        <div>@Html.Label("Postal Code", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">BT1 1EA</div>
        <div>@Html.Label("Priority", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">20/03/2017 17:04:36 +00:00</div>
        @*<div>@Html.Label("Calculation Specials", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">dfdfdfdfdfdfdfd</div>*@
    </div>
    <div class="row">
        <div>@Html.Label("Street", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">1A Royal Avenue</div>
        <div>@Html.Label("Phone", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">028 8044 6464</div>
        <div>@Html.Label("SAP Office Username", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">DBECKFOR</div>
        @*<div>@Html.Label("Created By", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">cvcvcvcvcv</div>*@
    </div>
    <div class="row">
        <div>@Html.Label("General Agreement Name", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">GeneralAgreementName</div>
        <div>@Html.Label("Is Day Business", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">True</div>
        <div>@Html.Label("Number Of Responsible Person", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">00001724</div>
        @*<div>@Html.Label("Created Date", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">20/03/2017 17:04:36 +00:00</div>*@
        @*<div>@Html.Label("Modified Date", htmlAttributes: new { @class = "editor-label col-sm-1" })</div><div class="col-sm-1 editor-field">20/03/2017 17:04:36 +00:00</div>*@
    </div>



</div>

【问题讨论】:

  • 我不明白目标是什么以及它与您的屏幕截图有何不同。
  • 如果您看到前三列标签和字段正确对齐,包含标签的第四列负责人姓名与值之间存在很大距离。我想减少该距离并在其旁边添加另一列包含标签和值

标签: html css asp.net-mvc-5


【解决方案1】:

由于您使用的是引导程序,因此您可以同时使用 col-md-2 5 次,或 col-md-1 10 次,并根据需要设置样式。

记住,如果你想使用 col-md-2,你应该使用 offset。

.col-md-1{
border-style: solid;
border-width: 1px !important;
border-color: black;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript" ></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" type="text/javascript" ></script>

<div class="row">
    <div class="col-xs-1 col-md-1">1</div>
    <div class="col-xs-1 col-md-1">2</div>
    <div class="col-xs-1 col-md-1">3</div>
    <div class="col-xs-1 col-md-1">4</div>
    <div class="col-xs-1 col-md-1">5</div>
    <div class="col-xs-1 col-md-1">6</div>
    <div class="col-xs-1 col-md-1">7</div>
    <div class="col-xs-1 col-md-1">8</div>
    <div class="col-xs-1 col-md-1">9</div>
    <div class="col-xs-1 col-md-1">10</div>             
</div>

【讨论】:

  • 那很好,但如果您看到我的控件包含在具有类的 div 中。我该如何应用它
  • 我在包含我的控件的 div 上的类正在扭曲布局
猜你喜欢
  • 1970-01-01
  • 2014-12-13
  • 1970-01-01
  • 1970-01-01
  • 2017-05-09
  • 2014-01-11
  • 2013-12-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多