因此,当mvc项目生成时,它有默认的母版页和部分视图,如注册视图和登录视图.问题是母版页在页面左侧和右侧都有默认的空格.我是问题是:写的边距空间代码在哪里以及如何删除它?它看起来很简单我似乎无法找到它.
Site.css保留其默认值:
body { padding-top: 50px; padding-bottom: 20px; } /* Set padding to keep content from hitting the edges */ .body-content { padding-left: 15px; padding-right: 15px; } /* Override the default bootstrap behavior where horizontal description lists will truncate terms that are too long to fit in the left column */ .dl-horizontal dt { white-space: normal; } /* Set width on the form input elements since they're 100% wide by default */ input,select,textarea { max-width: 280px; }
而且我的indes.cshtml非常简单:
@{ ViewBag.Title = "Home Page"; } <div id="mapa"> <h1>ASP.NET</h1> </div> <div id="content"> <div class="main-nav-wrapper"> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">WebSiteName</a> </div> <ul class="nav navbar-nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#">Page 1</a></li> <li><a href="#">Page 2</a></li> <li><a href="#">Page 3</a></li> </ul> </div> </nav> </div> </div>
我尝试将margin-left:0和margin-right:0添加到body-content类,但它只是将子页面向左移动并保持其大小.
解决方法
空白是因为默认情况下,通过Visual Studio创建的ASP.NET MVC项目使用
Bootstrap CSS Framework.我建议您学会使用它 – 它将使您的前端开发量更容易.
解决你的问题,你会发现任何一方带有“空白”的内容都嵌套在一个包含类容器的div中.删除此类并使用container-fluid将删除空白并使容器成为全屏宽度.
不要试图通过Bootstrap覆盖容器上设置的边距,否则会破坏Bootstrap在其他地方的样式.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。