全宽自举旋转木马

时间:2015-11-29 17:11:27

标签: html css twitter-bootstrap

我知道在这个网站上有很多关于全宽度引导旋转木马的问题,但我很困惑怎么办?! ,我花了一整天的时间来做这件事,但我不能...... 我给所有标签 margin padding 0px和 width 100%,但它不起作用:/

的site.css

body {
padding-top: 0px;
padding-bottom: 0px;
}

.body-content {
padding-left: 0px;
padding-right: 0px;
}
input,
select,
textarea {
max-width: 280px;
}

.field-validation-error {
color: #b94a48;
}

.field-validation-valid {
display: none;
}

input.input-validation-error {
border: 1px solid #b94a48;
}

input[type="checkbox"].input-validation-error {
border: 0 none;
}

.validation-summary-errors {
color: #b94a48;
}

.validation-summary-valid {
display: none;
}

Index.cshtml

@model NP1.ViewModels.HomeVM
@{
ViewBag.Title = "Home Page";
}
@section scripts{

}
@section styles{

}
<!-- start carousel -->

<div class="carousel slide" data-ride="carousel" data-interval="3000">
<div  class="carousel-inner">
    @foreach (var item in Model.Carousels)
    {

        if (item == Model.Carousels.FirstOrDefault())
        {
            <div  class="item active ">
                <img style="height:450px; width:100%;" class="img-responsive" src="@Url.Content(item.CarouselImage.ToString())">
                <div class="carousel-caption">
                    <h3>@item.CarouselSubject</h3>
                    <h4>@item.CarouselInfo</h4>
                </div>
            </div>
        }
        else
        {
            <div  class="item">
                <img style="height: 450px; width: 100%;" class="img-responsive" src="@Url.Content(item.CarouselImage.ToString())" />
                <div class="carousel-caption">
                    <h3>@item.CarouselSubject</h3>
                    <h4>@item.CarouselInfo</h4>
                </div>
            </div>
        }
    }
</div>

Layout.cshtml:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@RenderSection("styles", false)
</head>
<body class="container-fluid" style="width:100% !important;padding:0px;">
@*overflow-x:hidden;*@

<div class="container body-content">
@RenderBody()
<footer></footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", false)
</body>
</html>

4 个答案:

答案 0 :(得分:1)

试试这个

<div id="theCarousel" class="carousel slide" data-ride="carousel">
                    <ol class="carousel-indicators">
                        <li data-target="#theCarousel" data-slide-to="0" class="active"></li>
                        <li data-target="#theCarousel" data-slide-to="1"></li>
                        <li data-target="#theCarousel" data-slide-to="2"></li>
                    </ol>

                    <div class="carousel-inner">
                        <div class="item active">
                        <div class="slide1"></div>
                            <div class="carousel-caption">
                                <h1>Amazing Background</h1>
                            </div>
                        </div>
                        <div class="item">
                        <div class="slide2"></div>
                            <div class="carousel-caption">

                            </div>
                        </div>
                        <div class="item">
                        <div class="slide3"></div>
                            <div class="carousel-caption">

                            </div>
                        </div>
                    </div>
                </div>    

答案 1 :(得分:0)

而不是给你的身体container-fluid的类,然后将你的轮播包装在一个容器中。你应该把它放在你的html中:

<html>
 <body>
  <div class="container-fluid" style="padding: 0;">
   <!-- put your carousel in here -->
  </div>
 </body>
</html>

从这个小提琴复制html: http://jsfiddle.net/florianperrenet/shkt5wyh/

答案 2 :(得分:0)

您还必须更改您的CSS:

body {
padding-top: 0px;
padding-bottom: 0px;
width:100%;
height:100%
}

此代码''必须位于“容器”内的任何原因。

试试这个:

<div class="body-content">
   <div class="container-fluid">
      <!-- your carousel here-->
   </div>
</div>

答案 3 :(得分:0)

我意识到这是几年后的事了,但供以后参考:在“ _Layout.cshtml”视图中,您将看到:

<div class="container body-content">
     @RenderBody()
     <hr />
     <footer>
         <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
     </footer>
</div>

删除“容器”。那应该解决它。