gpt4 book ai didi

html - 为什么形成丢失的 Bootstrap css?

转载 作者:太空宇宙 更新时间:2023-11-04 11:59:35 24 4
gpt4 key购买 nike

我正在学习 MVC,我正在通过第一个代码制作联系表。你们谁能解释一下为什么消息区域比标题编辑器小,为什么它丢失了 bootstrap css?

@using (Html.BeginForm()) 
{
@Html.AntiForgeryToken()

<div class="form-horizontal">

<div class="form-group">
@Html.LabelFor(model => model.title, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.title, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.title, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.message, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.message, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.message, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="wyslij" class="btn btn-default" />
</div>
</div>
</div>
}

最佳答案

这是更新后的 Fiddle - https://dotnetfiddle.net/DWy02w

输出:

enter image description here

HTML :

@model HelloWorldMvcApp.SampleViewModel
@{
Layout = null;
}

<!DOCTYPE html>
<!-- template from http://getbootstrap.com/getting-started -->

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>

<!-- CSS Includes -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>

<body>
<div class="container col-md-10">
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<div class="form-group">
@Html.LabelFor(model => model.title, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.title, new { @class = "form-control" } )
@Html.ValidationMessageFor(model => model.title, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.message, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.message, new { @class = "form-control" } )
@Html.ValidationMessageFor(model => model.message, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="wyslij" class="btn btn-default" />
</div>
</div>
</div>
}
</div>
<!-- JS includes -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/4.0/jquery.validate.unobtrusive.min.js"></script>
</body>
</html>

模型:

using System;
using System.ComponentModel.DataAnnotations;

namespace HelloWorldMvcApp
{
public class SampleViewModel
{
public string title
{
get;
set;
}

public string message
{
get;
set;
}
}
}

关于html - 为什么形成丢失的 Bootstrap css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29941166/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com