HTML - 尝试将元素移动到页面底部

时间:2013-01-17 17:19:51

标签: html html5

下面是一个屏幕截图以及ASP MVC网站上的HTML副本。最后的段落元素(在代码的底部)与其他两个字段集水平排列,但是我需要它在页面的底部。 HTML /网页设计一直是我的致命弱点,所以如果有人能够解释发生的事情和可能的解决方案,我会非常感激。

@model Monet.Models.FollowUpItems

@{
ViewBag.Title = "Edit";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Edit Follow Up Item</h2>

<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)
<div>
<span style = "float:left;padding-right:4em">
<fieldset>
    <legend>Status Items</legend>

    <div class="error">
        @ViewBag.ErrorMessage
    </div>

    @Html.HiddenFor(model => model.Id)

    <div class="editor-label">
        @Html.LabelFor(model => model.Status)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Status)
        @Html.ValidationMessageFor(model => model.Status)
    </div>


    <div class="editor-label">
        @Html.LabelFor(model => model.Notes)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Notes)
        @Html.ValidationMessageFor(model => model.Notes)
    </div>
    <p>
        <input type="submit" value="Save" />
    </p>
</fieldset>
</span>
<span style="clear:both;"></span>
<span style="float:left;">
<fieldset>
    <legend>Basic Info</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.TableName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TableName)
            @Html.ValidationMessageFor(model => model.TableName)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Message)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Message)
            @Html.ValidationMessageFor(model => model.Message)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CreatedBy)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CreatedBy)
            @Html.ValidationMessageFor(model => model.CreatedBy)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CreatedOn)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CreatedOn)
            @Html.ValidationMessageFor(model => model.CreatedOn)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastUpdateBy)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastUpdateBy)
            @Html.ValidationMessageFor(model => model.LastUpdateBy)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastUpdateOn)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastUpdateOn)
            @Html.ValidationMessageFor(model => model.LastUpdateOn)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Key1)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Key1)
            @Html.ValidationMessageFor(model => model.Key1)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Key2)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Key2)
            @Html.ValidationMessageFor(model => model.Key2)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.IssueType)
        </div>
        <div class="editor-label">
            @Html.EditorFor(model => model.IssueType)
            @Html.ValidationMessageFor(model => model.IssueType)
        </div>
</fieldset>
</span>

</div>
<span style="clear:both;"></span> 
 }
 <span style="clear:both;"></span>
 <p>
     @Html.ActionLink("Back to List", "Index")
 </p> 

enter image description here

2 个答案:

答案 0 :(得分:1)

我无法从您的代码中判断清除范围是否设置为display:block,但我预感它应该是:

<span style="display:block;clear:both;"></span>

答案 1 :(得分:0)

Span是inline元素

替换它:

<span style = "float:left;padding-right:4em">

使用:

<div style = "float:left;padding-right:4em; overflow: hidden;">

是的,请将所有<span>转换为<div>并检查。