GVKun编程网logo

html – 浮动左右比包装div大?(html左右浮动代码)

1

在本文中,我们将带你了解html–浮动左右比包装div大?在这篇文章中,我们将为您详细介绍html–浮动左右比包装div大?的方方面面,并解答html左右浮动代码常见的疑惑,同时我们还将给您一些技巧,

在本文中,我们将带你了解html – 浮动左右比包装div大?在这篇文章中,我们将为您详细介绍html – 浮动左右比包装div大?的方方面面,并解答html左右浮动代码常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处、asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net-mvc – Html.BeginForm()工作正常,Html.BeginForm(“action”,“controller”)忽略[AllowHtmlAttribute]

本文目录一览:

html – 浮动左右比包装div大?(html左右浮动代码)

html – 浮动左右比包装div大?(html左右浮动代码)

参见英文答案 > Why does CSS padding increase size of element?                                    6个
我正在尝试在我的电子邮件模板中创建彩色列部分.我遇到的问题是包含所有电子邮件内容的内容包装器是根据下面的代码设置的.同样,包括浮动列CSS.

#content {
  background-color: white;
  margin: auto;
  width: 600px;
  color: #888;
  font-size: 12px;
  border-radius: .6em .6em 0em 0em;
  Box-shadow: 0px 0px 15px 0px #555;
}
.blueLeft {
  background-color: #33ccff;
  float: left;
  display: block;
  width: 300px;
  padding: 20px;
  font-size: 16px;
}
.blueRight {
  background-color: #33ccff;
  float: right;
  display: block;
  width: 300px;
  padding: 20px;
  font-size: 16px;
}
<div id="content">
   <div>
      <p>
         Lorem ipsum dolor sit amet,consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
      </p> 
   </div>
   <div>
      <p>
           Lorem ipsum dolor sit amet,quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
      </p> 
   </div><div></div>
</div>

如您所见,内容包装器的宽度为:600px;,每列为300px.那么你会期望列将填充包装器宽度的100%,其间没有空间.将宽度设为50%是同样的问题.所以,某种程度上,#content显示的比它应该的要小.

如何编辑它以使每列真正占据内容宽度的50%?

结果是这样的:

css problems

解决方法

这是因为你有宽度和填充.

如果你将box-sizing: border-box;添加到.blueLeft和.blueRight,它应该修复你的宽度问题.

有关其工作原理和方式的更多信息,请参见MDN documentation on the CSS Box Model.

ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

1.Action、RenderAction加载办法的视图,履行Controller → Model → View的次序,然后把产生的页面带回到本来的View中再回传。而Partial、RenderPartial直接加载视图文件内容

2.Html.Partial可以直接供给用户控件名作为参数,而Html.Action须要有对应的Action,在Action内部返回PartailResult(即retun PartialView())。

3.对于简单的没有任何逻辑的用户控件,推荐应用Html.Partial;对于须要设置一些Model的用户控件,推荐应用Html.Action。当然,有Model数据也是可以应用Html.Partial办法的,可以看办法的重载。

4.Html.Partial与Html.Action有啥区别呢?区别就是,Html.Partial只有一个视图,而Html.Action除了视图,还真的有个Action跟它对应,所以,Html.Action功能比Html.Partial要强。

 

如何调用这个Html.Partial

 //1、以视图名使用当前文件夹下的视图(如果没有找到,则搜索 Shared 文件夹)
@Html.Partial( "_test" //加载对应文件 /Views/Product/_test.cshtml
 
//2、依据应用根路径定位视图// 以 "/" 或 "~/" 开头的路径代表应用根路径
@Html.Partial( "~/Views/Product/_test.cshtml" )
@Html.Partial( "/Views/Product/_test2.cshtml" )
 
//3、加载其他目录的 视图文件
//注意:需要复制views中的web.config 到template目录,否则会提示  "/template/A.cshtml”处的视图必须派生自 WebViewPage 或 WebViewPage<TModel>"
@Html.Partial( "/template/A.cshtml" )

asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处

asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处

在ASP.NET MVC中,有什么区别:

Html.Partial and Html.RenderPartial
Html.Action and Html.RenderAction

解决方法

Html.Action调用控制器的动作,这意味着它实例化控制器实体,调用动作方法,构建模型并返回视图结果.

Html.Partial使用已创建的模型(或者可以在没有模型的情况下调用)来渲染指定的视图.

何时使用一个而不是另一个?如果您已有模型并且只想拥有可重复使用的视图,请选择Html.Partial.如果你看到某个部分值得拥有自己的模型和动作,那么使用Html.Action可能是有意义的.

这个问题在this article中有更详细的讨论,你在上面看到的基本上是它的摘录.

asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction

1、带有Render的方法返回值是void,在方法内部进行输出;不带的返回值类型为MvcHtmlString,所以只能这样使用:

     @Html.Partial 对应 @{Html.RenderPartial(....);}@Html.Action 对应 @{Html.RenderAction(....);}

2、Html.Partial可以直接提供用户控件名作为参数,

    而Html.Action需要有对应的Action,在Action内部返回PartailResult(即retun PartialView())。

3、对于简单的没有任何逻辑的用户控件,推荐使用Html.Partial;对于需要设置一些Model的用户控件,推荐使用Html.Action。当然,有         Model数据也是可以使用Html.Partial方法的,可以看方法的重载。

4、使用Html.Action有个好处,就是可以根据不同的场景选择不同的用户控件。比如:@Html.Action("UserInfoControl")在对应的    UserInfoControl这个Action中,在用户未登录的时候,可以retun PartialView("LogOnUserControl");登录后,可以retun  PartialView("UserInfoControl");

asp.net-mvc – Html.BeginForm()工作正常,Html.BeginForm(“action”,“controller”)忽略[AllowHtmlAttribute]

asp.net-mvc – Html.BeginForm()工作正常,Html.BeginForm(“action”,“controller”)忽略[AllowHtmlAttribute]

我在我的网站的管理面板上使用 TinyMCE editor,所以我用[AllowHtml]装饰模型属性(tinymce的目标),并在视图中使用Html.BeginForm().当我提交带有HTML字段的表单时,一切正常.

但是我有一个问题,如果我以相同的方式使用重载Html.BeginForm(“action”,“controller”),它会跳过[AllowHtml]并抛出众所周知的Request.form异常.
我被迫在Action-Method上使用[ValidateInput(false)]来使它无异常地工作.
你知道为什么吗?在此先感谢您的澄清,

这是方案/项目:Asp.net Mvc 4:

型号/ Ricetta.cs

..
[required(ErrorMessage = "Corpo Articolo vuoto")]
[AllowHtml]
public string corpoTesto { get; set; }
..

Controller / RicetteController.cs

..
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create(Ricettaviewmodel modelloRicetta)
    {
        if (ModelState.IsValid) {
..

查看Ricette / Create从RicetteController中的另一个Action方法调用为View(“Create”,modelObject)

@model WebAPP_MVC4.Areas.Admin.Models.Ricettaviewmodel
 ...
 @using (Html.BeginForm("Create","Ricette",FormMethod.Post)){
 @Html.AntiForgeryToken()
 @Html.ValidationSummary(true)

....

<fieldset>
    <legend>Corpo Ricetta ~</legend>
    <div>
        @Html.LabelFor(p=>p.ricetta.corpoTesto)
    </div>
    <div>
        @Html.TextAreaFor(p=>p.ricetta.corpoTesto,new { @cols = 60,@rows = 20})
        @Html.ValidationMessageFor(p=>p.ricetta.corpoTesto)
    </div>
 </fieldset>
..

解决方法

我做了快速测试,一切正常,Html.BeginForm()和Html.BeginForm(“action”,“controller”)之间的行为没有区别.也许这个问题的原因在于您没有向我们展示的源代码.

在我的代码(工作)下面:
VieModel:

public class Postviewmodel
{
    [AllowHtml]
    [required]
    public string Content { get; set; } 
}

控制器:

public ActionResult Index()
{
    return View("Create",new Postviewmodel());
}

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Postviewmodel model)
{
    if (ModelState.IsValid)
    {
        return Index();
    }
    return View(model);
}

视图:

@model SendHTmlTpControler.Models.Postviewmodel

<html>
<head>
    <script src="~/Scripts/tinymce/tiny_mce.js"></script>

    <script type="text/javascript">
        tinymce.init({
            selector: "textarea",toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
        });
    </script>
</head>
<body>
    <h2>Create</h2>

    @using (Html.BeginForm("Create","Home",FormMethod.Post))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <div>
            @Html.LabelFor(model => model.Content)
        </div>
        <div>
            @Html.TextAreaFor(model => model.Content,@rows = 20 })
            @Html.ValidationMessageFor(model => model.Content)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    }

</body>
</html>

今天的关于html – 浮动左右比包装div大?html左右浮动代码的分享已经结束,谢谢您的关注,如果想了解更多关于ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处、asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net-mvc – Html.BeginForm()工作正常,Html.BeginForm(“action”,“controller”)忽略[AllowHtmlAttribute]的相关知识,请在本站进行查询。

本文标签: