0

I know there are many questions about full width bootstrap carousel in this site , but I'm confused how do it?! , I spend all the day to do this but I couldn't ... I give all tags margin and padding 0px and width 100% but it didn't work :/

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>
shima amini
  • 121
  • 1
  • 11

4 Answers4

1

Try This

<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>    
Raza Ali Poonja
  • 1,086
  • 8
  • 16
0

Instead of giving your body the class of container-fluid and then wrapping your carousel in a container. You should put it in your html like this:

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

Copy the html from this fiddle: http://jsfiddle.net/florianperrenet/shkt5wyh/

0

You also have to change your css:

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

Any reason why this code '' has to be inside of the "container".

Try this:

<div class="body-content">
   <div class="container-fluid">
      <!-- your carousel here-->
   </div>
</div>
Franco
  • 2,309
  • 1
  • 11
  • 18
0

I realize this is years later, but for future reference: inside your '_Layout.cshtml' view you will see:

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

Remove "container". That should fix it.