[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 512
  • Last Modified:

bootstrap div css styling

I'm using Visual Studio 2013 and I am working on a ASP.NET MVC 4 application using the basic template and C# and razor syntax.

So i have a view that is made up of 3 partial views the top is the header, the body is another and the footer is the third partial view.

In the body partial view I have a div that looks like this and this is the main container div for anything in the body.

<div class="container">

</div>


in the bootstrap.css style sheet I have the following items:

.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

@media (min-width: 768px) {
  .container {
    width: 750px;
  }
}
@media (min-width: 992px) {
  .container {
    width: 970px;
  }
}
@media (min-width: 1200px) {
  .container {
    width: 1170px;
  }
}
.container-fluid {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;

}

Open in new window


So when I run my page I get something that looks like this:
When I look at the div properties of my rendered page I see that the width of this div in the body is 1170px

my page showing the size of my div when i select inspect element in chrome web browser
If I reduce the browser window size horizontally(the width of my browser window with my mouse), then the width of my div seems to resize to 970px as shown here:

my page showing the size of my div when i select inspect element in chrome web browser
Then if I continue to reduce the width size of my web browser window then the width of my div seems to resize to 750px as shown here:

my page showing the size of my div when i select inspect element in chrome web browser

So from resizing my web browser window I see that my div resizes to those three width sizes shown above that are declared in the bootstrap.css.

How do I revise my style sheet so my page does the following? Can anyone help?

When I resize my browser window width... I don't want it to jump from width: 1170px to width: 970px and then to width: 750px

I just want my div to stay at a width of 1170px.
If I make the browser window width smaller. I want the width of my div to remain at 1170px and just show at horizontal scrollbar on the bottom of the browser window.


I read that if I can turn any fixed-width grid layout into a full-width layout by changing your outermost .container to .container-fluid.

I changed the tag of my div to

<div class="container-fluid">

</div>

When I do this it stopped resizing it to the three width sizes from above but it stretches the full width of the screen past a width of 1170px.  If I change it to container-fluid which is one of the default css classes in bootstrap.css can I just set the min and maximum width of this class to 1170px so it doesn't stretch or get smaller. I just want the width to stay at 1170px.
0
maqskywalker
Asked:
maqskywalker
1 Solution
 
GaryCommented:
Add this after the boostrap.css

@media (min-width: 0px) {
  .container {
    width: 1170px;
  }
}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now