search
HomeWeb Front-endBootstrap TutorialWhat layout methods does bootstrap have?

What layout methods does bootstrap have?

What layout methods does bootstrap have?

bootstrap has fixed layout and fluid layout: fixed layout creates a web page or app based on a fixed number of pixels; fluid layout creates a non-fixed layout, that is, a percentage-based layout to make the layout more dynamic. flexible.

Related recommendations: "bootstrap Tutorial"

Bootstrap Fixed Layout

If you want to create a layout based on a fixed number of pixels Web page or app, please see the tutorial in this part.

Usage

<body>
  <div>
    ...
  </div>
</body>

                                                                                                                                                                                             

Explanation

## line to create a main container rendering style, thereby creating a fixed layout. The purpose of a fixed layout is to create a 940 pixel (default) wide layout for a web page or app.

Example of Bootstrap fixed layout

What layout methods does bootstrap have?

The following code creates a fixed layout for a web page. For customization, in addition to the default styles, create a new css file example-fixed-layout.css in the same folder as bootstrap.css.

CSS Code

body {
padding-top: 60px;
padding-bottom: 40px;
}
.nav li {
padding-top: 5px;
}
.leaderboard {
padding: 60px;
margin-bottom: 30px;
background-image: url(&#39;/twitter-bootstrap/images/gridbg.gif&#39;);
background-repeat:repeat;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
.leaderboard h1 {
font-size: 40px;
margin-bottom: 5px;
line-height: 1;
letter-spacing: -1px;
color:#FF6600;
}
.leaderboard p {
font-size: 18px;
font-weight: 200;
line-height: 27px;
}


HTML 代码
实例
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>使用Bootstrap 版本 2.0 固定布局的实例</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Example of Fixed Layout with Bootstrap version 2.0 from w3cschool.cc">
    <meta name="author" content="">
    <!-- Le styles -->
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/example-fixed-layout.css" rel="stylesheet">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
        <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/favicon.ico">
    <link rel="apple-touch-icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-114x114.png">
</head>
<body>
    <div class="navbar navbar-fixed-top">
        <div>
            <div>
                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span></span>
                    <span></span>
                    <span></span>
                </a>
                <a href="#">
                    <img src="/static/imghwm/default1.png"  data-src="/images/w3r.png"  class="lazy"      style="max-width:90%"  style="max-width:90%" alt="w3cschool logo" /></a>
                <div>
                    <ul>
                        <li>
                            <a href="#">Home</a></li>
                        <li>
                            <a href="#about">About</a></li>
                        <li>
                            <a href="#contact">Contact</a></li>
                    </ul>
                </div>
                <!--/.nav-collapse --></div>
        </div>
    </div>
    <div>
        <!-- Main hero unit for a primary marketing message or call to action -->
        <div>
            <h1 id="w-cschool-nbsp-Web-nbsp-Store">w3cschool Web Store</h1>
            <p>Try and purchase HTML5, JS, Ruby, PHP-MySQL based web apps to enhance your productivity at affordable price.</p>
            <p>
                <a class="btn btn-success btn-large">Sign Up for a 30 day free trial</a></p>
        </div>
        <!-- Example row of columns -->
        <div>
            <div>
                <h2 id="HTML-nbsp-and-nbsp-JS-nbsp-Apps">HTML5 and JS Apps</h2>
                <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh,ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                <p>
                    <a class="btn btn-success btn-large" href="#">View apps</a></p>
            </div>
            <div>
                <h2 id="Ruby-nbsp-Apps">Ruby Apps</h2>
                <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh,ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                <p>
                    <a class="btn btn-success btn-large" href="#">View apps</a></p>
            </div>
            <div>
                <h2 id="PHP-nbsp-MySQL-nbsp-Apps">PHP MySQL Apps</h2>
                <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
                <p>
                    <a class="btn btn-success btn-large" href="#">View apps</a></p>
            </div>
        </div>
        <hr>
        <footer>
            <p>&copy; Company 2012</p>
        </footer>
    </div>
    <!-- /container -->
    <!-- Le javascript==================================================- ->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-transition.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-modal.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-scrollspy.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tab.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tooltip.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-popover.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-button.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-collapse.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-carousel.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
Output

View the above example in a different browser window.

Bootstrap Fluid Layout

If you want to create a non-fixed layout, that is, a percentage-based layout to make the layout more flexible, please read this part of the tutorial. Usage

<div>
  <div>
    <div>
      <!--Sidebar content-->
    </div>
    <div>
      <!--Body content-->
    </div>
  </div>
</div>

Explanation

Lines 274 to 285 of bootstrap.css (located under docs\assets\css in bootstrap's main folder) create the main container Render styles to create a flowing layout. The purpose of fluid layout is to create a percentage-based layout (for example, width=20%) for a web page or app.

Bootstrap Fluid Layout Example

What layout methods does bootstrap have?

The following code creates a web page fluid layout. For customization, in addition to the default styles, create a new css file example-fluid-layout.css in the same folder as bootstrap.css. ######CSS Code###
 body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      .nav li {
      padding-top: 5px;
      }
      
      .sidebar-nav {
        padding: 9px 0;
      }
      .leaderboard {
  padding: 60px;
  margin-bottom: 30px;
  background-image: url(&#39;/twitter-bootstrap/images/gridbg.gif&#39;);
  background-repeat:repeat;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
}
.leaderboard h1 {
  font-size: 40px;
  margin-bottom: 5px;
  line-height: 1;
  letter-spacing: -1px;
  color:#FF6600;
}
.leaderboard p {
  font-size: 18px;
  font-weight: 200;
  line-height: 27px;
}
.well {
background-image: url(&#39;/twitter-bootstrap/images/gridbg.gif&#39;);
  background-repeat:repeat;
  -webkit-border-radius: 6px;
  -moz-border-radius: 6px;
  border-radius: 6px;
}
.nav .nav-header {
font-size: 18px;
color:#FF9900;
}
HTML 代码
实例
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>使用Bootstrap 版本 2.0 固定布局的实例</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Example of Fluid Layout with Bootstrap version 2.0 from w3cschool.cc">
    <meta name="author" content="">
    <!-- Le styles -->
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/bootstrap.css" rel="stylesheet">
    <link href="../bootstrap/twitter-bootstrap-v2/docs/assets/css/example-fluid-layout.css" rel="stylesheet">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/favicon.ico">
    <link rel="apple-touch-icon" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="../bootstrap/twitter-bootstrap-v2/docs/examples/images/apple-touch-icon-114x114.png"></head>
<body>
    <div class="navbar navbar-fixed-top">
        <div>
            <div>
                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span></span>
                    <span></span>
                    <span></span>
                </a>
                <a href="#">
                    <img src="/static/imghwm/default1.png"  data-src="/images/w3r.png"  class="lazy"      style="max-width:90%"  style="max-width:90%" alt="w3cschool logo" /></a>
                <div>
                    <ul>
                        <li>
                            <a href="#">Home</a></li>
                        <li>
                            <a href="#about">About</a></li>
                        <li>
                            <a href="#contact">Contact</a></li>
                    </ul>
                    <p class="navbar-text pull-right">Logged in as
                        <a href="#">username</a></p>
                </div>
                <!--/.nav-collapse --></div>
        </div>
    </div>
    <div>
        <div>
            <div>
                <div class="well sidebar-nav">
                    <ul class="nav nav-list">
                        <li>Frontend</li>
                        <li>
                            <a href="#">HTML 4.01</a></li>
                        <li>
                            <a href="#">HTML5</a></li>
                        <li>
                            <a href="#">CSS</a></li>
                        <li>
                            <a href="#">JavaScript</a></li>
                        <li>
                            <a href="#">Twitter Bootstrap</a></li>
                        <li>
                            <a href="#">Firebug</a></li>
                        <li>Backend</li>
                        <li>
                            <a href="#">PHP</a></li>
                        <li>
                            <a href="#">SQL</a></li>
                        <li>
                            <a href="#">MySQL</a></li>
                        <li>
                            <a href="#">PostgreSQL</a></li>
                        <li>
                            <a href="#">MongoDB</a></li>
                    </ul>
                </div><!--/.well -->
            </div><!--/span-->
            <div>
                <div>
                    <h1 id="Learn-nbsp-Practice-nbsp-Develop">Learn. Practice. Develop.</h1>
                    <p>w3cschool offers web development tutorials. We believe in Open Source. Love standards. And prioritize simplicity and readability while serving content.</p>
                    <p>
                        <a class="btn btn-success btn-large">Join w3cschool now</a></p>
                </div>
                <div>
                    <div>
                        <h2 id="Learn">Learn</h2>
                        <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                        <p>
                            <a class="btn btn-success btn-large" href="#">Start Learning now</a></p>
                    </div><!--/span-->
                    <div>
                        <h2 id="Practice">Practice</h2>
                        <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                        <p>
                            <a class="btn btn-success btn-large" href="#">Start percticing now</a></p>
                    </div>
                    <!--/span-->
                    <div>
                        <h2 id="Develop">Develop</h2>
                        <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.</p>
                        <p>
                            <a class="btn btn-success btn-large" href="#">Start developing now</a></p>
                    </div><!--/span-->
                </div><!--/row-->
                <hr>
                <footer>
                    <p>&copy; Company 2012</p>
                </footer>
            </div>
        </div>
    </div><!--/.fluid-container-->
    
    <!-- Le javascript==================================================- ->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/jquery.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-transition.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-alert.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-modal.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-dropdown.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-scrollspy.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tab.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-tooltip.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-popover.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-button.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-collapse.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-carousel.js"></script>
    <script src="../bootstrap/twitter-bootstrap-v2/docs/assets/js/bootstrap-typeahead.js"></script>
</body>
</html>
###Output############

The above is the detailed content of What layout methods does bootstrap have?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is Bootstrap? An Introduction for BeginnersWhat is Bootstrap? An Introduction for BeginnersApr 22, 2025 am 12:07 AM

BootstrapisafreeCSSframeworkthatsimplifieswebdevelopmentbyprovidingpre-styledcomponentsandJavaScriptplugins.It'sidealforcreatingresponsive,mobile-firstwebsites,offeringaflexiblegridsystemforlayoutsandasupportivecommunityforlearningandcustomization.

Bootstrap Demystified: A Simple ExplanationBootstrap Demystified: A Simple ExplanationApr 21, 2025 am 12:13 AM

Bootstrapisafree,open-sourceCSSframeworkthathelpscreateresponsive,mobile-firstwebsites.1)Itoffersagridsystemforlayoutflexibility,2)includespre-styledcomponentsforquickdesign,and3)ishighlycustomizabletoavoidgenericlooks,butrequiresunderstandingCSStoop

Bootstrap vs. React: Choosing the Right ApproachBootstrap vs. React: Choosing the Right ApproachApr 20, 2025 am 12:09 AM

Bootstrap is suitable for quick construction and small projects, while React is suitable for complex and interactive applications. 1) Bootstrap provides predefined CSS and JavaScript components to simplify responsive interface development. 2) React improves performance and interactivity through component development and virtual DOM.

Bootstrap's Purpose: Building Consistent and Attractive WebsitesBootstrap's Purpose: Building Consistent and Attractive WebsitesApr 19, 2025 am 12:07 AM

The main purpose of Bootstrap is to help developers quickly build responsive, mobile-first websites. Its core functions include: 1. Responsive design, which realizes layout adjustments of different devices through a grid system; 2. Predefined components, such as navigation bars and modal boxes, ensure aesthetics and cross-browser compatibility; 3. Support customization and extensions, and use Sass variables and mixins to adjust styles.

Bootstrap vs. Other Frameworks: A Comparative OverviewBootstrap vs. Other Frameworks: A Comparative OverviewApr 18, 2025 am 12:06 AM

Bootstrap is better than TailwindCSS, Foundation, and Bulma because it is easy to use and quickly develop responsive websites. 1.Bootstrap provides a rich library of predefined styles and components. 2. Its CSS and JavaScript libraries support responsive design and interactive functions. 3. Suitable for rapid development, but custom styles may be more complicated.

Integrating Bootstrap Styles in React: Methods and TechniquesIntegrating Bootstrap Styles in React: Methods and TechniquesApr 17, 2025 am 12:04 AM

Integrating Bootstrap in React projects can be done in two ways: 1) introduced using CDN, suitable for small projects or rapid prototyping; 2) installation using npm package manager, suitable for scenarios that require deep customization. With these methods, you can quickly build beautiful and responsive user interfaces in React.

Bootstrap in React: Advantages and Best PracticesBootstrap in React: Advantages and Best PracticesApr 16, 2025 am 12:17 AM

Advantages of integrating Bootstrap into React projects include: 1) rapid development, 2) consistency and maintainability, and 3) responsive design. By directly introducing CSS files or using the React-Bootstrap library, you can use Bootstrap's components and styles efficiently in your React project.

Bootstrap: A Quick Guide to Web FrameworksBootstrap: A Quick Guide to Web FrameworksApr 15, 2025 am 12:10 AM

Bootstrap is a framework developed by Twitter to help quickly build responsive, mobile-first websites and applications. 1. Ease of use and rich component libraries make development faster. 2. The huge community provides support and solutions. 3. Introduce and use class names to control styles through CDN, such as creating responsive grids. 4. Customizable styles and extension components. 5. Advantages include rapid development and responsive design, while disadvantages are style consistency and learning curve.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor