In bootstrap, many threaded style components are provided. These styles are written by less. You do not need to know less to use bootstrap. Less includes a set of custom syntax and a parser to generate corresponding css files. .
The operating environment of this tutorial: Windows 10 system, bootstrap version 3.3.7, DELL G3 computer
What is the relationship between bootstrap and less
In bootstrap, many threaded style components are provided. These styles are written by less. You do not need to know less to use bootstrap.
bootstrap project architecture
Implementing layout system and content
1) Design of grid system Supplementary content: column sorting col-md-push- 4
2) Complete the content of the cell
Style customization
less
Modify bootstrap source Code
less
#css is a markup language with simple syntax and low learning difficulty. However, CSS requires writing a large amount of seemingly illogical code and is inconvenient to maintain. And expansion is not conducive to reuse. A big reason for these difficulties is that CSS is a non-programmed language and has no concepts such as variables, functions, and SCOPE (scope).
LESS includes a set of custom grammars and a parser. Users define their own style rules based on these grammars. These rules will eventually be compiled by the parser to generate corresponding CSS files.
LESS does not cut out the original features of CSS, nor is it used to replace CSS. Instead, it adds procedural language features to CSS based on the existing CSS syntax. Less is based on the syntax of CSS and introduces functions such as variables, Mixin (mixing), operations and functions, which greatly simplifies the writing of CSS and reduces the maintenance cost of CSS.
Less can run On Node or browser side.
Method 1 - Run the less conversion program on the client
Introduce xx.less into html, and then introduce less.js, which is a less that can run in the client browser Compiler program -- low efficiency, not recommended. Method 2 - run less conversion program on the server side - recommended
1) Download and install a server-side js interpreter-nodejs
2) Download the lessc file conversion program lessc --js script
3) Run the lessc converter on the server-side js interpreter to convert the .less file you wrote into a css file
a) You can use the conversion program in the command line
node.exe lessc my.less my.css
b) Use the conversion program in hbuilder
4) In the html file, reference the compiled css file
2. Less syntax learning
less fully supports css syntax
lss supports single-line comments and multi-line comments, but only multi-line comments will be converted to css files
less supports variables (variable)
ˆ @variable name: value
ˆ Use: selector {style: @variable name}
less supports style mixing-in one Another style is referenced in the style
.class1(){...} .class2{ ... .class1 ... }
Mixed with parameters
.class()(@参数1,@参数2,。。。){....} .class2 { ... .class(参数1,参数2); ... }
Nested rules
.class1{ ... .class2 {} }
The result of conversion
.class1{ } .class1 .class2{ }
less can be performed on variables and constants Arithmetic operations
less provides dozens of application functions for styles
lighten(color, brightness value): Brighten the specified color by the specified percentage
darken(color , brightness value): darken the specified color by the specified percentage
floor(number) log value rounded down
ceil(number) log value rounded up
Page import
Try to avoid using the @import directive in the css file - it will increase the number of HTTP requests
In order to split a style file into multiple small style files, multiple people can use it at the same time When writing, you can use @import-less in less to import other less files. During conversion, a large and complete css style file will be spliced, so it is recommended to import other less files in less
<code> @import "xx.less"</code>
**Large projects Medium less file structure**
variable.less - place all variables
mixin.less - place all mixin
reset.less - place HTML elements Reset style
navbar.less - Navigation bar related
footer.less - Footer related style
js.less - A lot of less files
3. Achieve style customization by modifying the less source file of bootstrap
Delete unnecessary styles, such as carousel ads/modal boxes
In the bootstrap.less file, comment Just remove the unnecessary @import
Customize the default style of the required components, such as modifying the default background color of the navigation bar
Just modify the variables in the variables.less file
Create a new style based on the default style provided by bootstrap, such as customizing the style of the divider in dropdown - in-depth customization of components
Modify the less file corresponding to a component
Related recommendations: bootstrap tutorial
The above is the detailed content of What is the relationship between bootstrap and less?. For more information, please follow other related articles on the PHP Chinese website!

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.

Bootstrapisafree,open-sourceCSSframeworkthatsimplifiesresponsiveandmobile-firstwebsitedevelopment.Itofferspre-styledcomponentsandagridsystem,streamliningthecreationofaestheticallypleasingandfunctionalwebdesigns.

What makes web design easier is Bootstrap? Its preset components, responsive design and rich community support. 1) Preset component libraries and styles allow developers to avoid writing complex CSS code; 2) Built-in grid system simplifies the creation of responsive layouts; 3) Community support provides rich resources and solutions.

Bootstrap accelerates web development, and by providing predefined styles and components, developers can quickly build responsive websites. 1) It shortens development time, such as completing the basic layout within a few days in the project. 2) Through Sass variables and mixins, Bootstrap allows custom styles to meet specific needs. 3) Using the CDN version can optimize performance and improve loading speed.

Bootstrap is an open source front-end framework, and its main function is to help developers quickly build responsive websites. 1) It provides predefined CSS classes and JavaScript plug-ins to facilitate the implementation of complex UI effects. 2) The working principle of Bootstrap relies on its CSS and JavaScript components to realize responsive design through media queries. 3) Examples of usage include basic usage, such as creating buttons, and advanced usage, such as custom styles. 4) Common errors include misspelling of class names and incorrectly introducing files. It is recommended to use browser developer tools to debug. 5) Performance optimization can be achieved through custom build tools, best practices include predefined using semantic HTML and Bootstrap

Bootstrap implements responsive design through grid systems and media queries, making the website adapted to different devices. 1. Use a predefined class (such as col-sm-6) to define the column width. 2. The grid system is based on 12 columns, and it is necessary to note that the sum does not exceed 12. 3. Use breakpoints (such as sm, md, lg) to define the layout under different screen sizes.

Bootstrap is an open source front-end framework for rapid development of responsive websites and applications. 1. It provides the advantages of responsive design, consistent UI components and rapid development. 2. The grid system uses flexbox layout, based on 12-column structure, and is implemented through classes such as .container, .row and .col-sm-6. 3. Custom styles can be implemented by modifying SASS variables or overwriting CSS. 4. Commonly used JavaScript components include modal boxes, carousel diagrams and folding. 5. Optimization performance can be achieved by loading only necessary components, using CDN, and compressing merge files.

Bootstrap and JavaScript can be seamlessly integrated to give web pages dynamic functionality. 1) Use JavaScript to manipulate Bootstrap components, such as modal boxes and navigation bars. 2) Ensure jQuery loads correctly and avoid common integration problems. 3) Achieve complex user interaction and dynamic effects through event monitoring and DOM operations.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software