Bootstrap इत्यनेन सह LESS इत्यस्य उपयोगः

Bootstrap इत्यस्य CSS इत्यस्य निर्माणार्थं प्रयुक्तानां चरानाम्, mixins, इत्यादीनां लाभं ग्रहीतुं LESS , CSS पूर्वसंसाधकेन सह Bootstrap इत्यस्य अनुकूलनं विस्तारं च कुर्वन्तु ।

LESS किमर्थम् ?

Bootstrap इत्यस्य मूलं LESS इत्यनेन सह निर्मितम् अस्ति, अस्माकं सुहृद्, Alexis Sellier इत्यनेन निर्मितं गतिशीलं शैलीपत्रकभाषा । एतेन सिस्टम्-आधारित-CSS-विकासः द्रुततरः, सुलभः, अधिकं च मजेयः भवति ।

किं समाविष्टम् अस्ति ?

CSS इत्यस्य विस्ताररूपेण LESS इत्यत्र चराः, कोडस्य पुनःप्रयोज्यस्निपेट् कृते मिक्सिन्, सरलगणितस्य कृते क्रियाः, नेस्टिङ्ग्, अपि च वर्णकार्यं च समाविष्टम् अस्ति ।

अधिकं ज्ञातुं शक्नुवन्ति

LESS CSS इति

अधिकं ज्ञातुं http://lesscss.org/ इति आधिकारिकजालस्थलं पश्यन्तु ।

चर

CSS मध्ये वर्णानाम्, पिक्सेलमूल्यानां च प्रबन्धनं किञ्चित् दुःखं भवितुम् अर्हति, प्रायः प्रतिलिपि-चिनोतिभिः पूर्णम् । न तु LESS इत्यनेन सह—वर्णान् वा पिक्सेलमूल्यानि वा चररूपेण नियुक्तं कृत्वा एकवारं परिवर्तयन्तु ।

मिक्सिन्

तानि त्रीणि सीमा-त्रिज्या-घोषणानि भवन्तः नियमितरूपेण ol' CSS मध्ये कर्तुं आवश्यकाः? इदानीं ते mixins इत्यस्य साहाय्येन एकां पङ्क्तिं यावत् अधः सन्ति, कोडस्य स्निपेट् भवन्तः कुत्रापि पुनः उपयोक्तुं शक्नुवन्ति ।

संचालन

ऑपरेशनों के साथ मक्खी पर गणित करके अपनी जाल, अग्रणी, और अधिक सुपर लचीला करें। CSS sanity इत्यस्य मार्गं गुणयतु, विभज्य, योजयतु, घटयतु च ।

मचान एवं लिंक

@bodyBackground @white पृष्ठ पृष्ठभूमि रंग
@textColor @grayDark सम्पूर्णशरीरस्य, शीर्षकस्य, इत्यादीनां कृते पूर्वनिर्धारितं पाठवर्णम्
@linkColor #08c पूर्वनिर्धारित लिङ्क पाठ रंग
@linkColorHover darken(@linkColor, 15%) पूर्वनिर्धारित लिङ्क पाठ होवर रंग

जाल प्रणाली

@gridColumns १२
@gridColumnWidth ६०px इति
@gridGutterWidth २०px इति
@fluidGridColumnWidth ६.३८२९७८७२३% २.
@fluidGridGutterWidth २.१२७६५९५७४% २.

टाइपोग्राफी

@sansFontFamily "हेल्वेटिका न्यू", हेल्वेटिका, एरियल, sans-serif
@serifFontFamily Georgia, "Times New Roman", Times, serif
@monoFontFamily मेनलो, मोनाको, "कूरियर नई", मोनोस्पेस
@baseFontSize १३px पिक्सेलः भवितुमर्हति
@baseFontFamily @sansFontFamily
@baseLineHeight १८px इति पिक्सेलः भवितुमर्हति
@altFontFamily @serifFontFamily
@headingsFontFamily inherit
@headingsFontWeight bold
@headingsColor inherit

सारणीः

@tableBackground transparent
@tableBackgroundAccent #f9f9f9
@tableBackgroundHover #f5f5f5
@tableBorder ddd

ग्रेस्केल रंग

@black # 000
@grayDarker # 222
@grayDark # 333
@gray # 555
@grayLight # 999
@grayLighter # ईई
@white # fff

उच्चारण रंग

@blue # 049cdb
@green # ४६अ५४६
@red # 9d261d
@yellow # ffc40d
@orange # च८९४०६
@pink # ग3325च
@purple # ७अ४३ख६

घटकाः

बटन्स्

@btnBackground @white
@btnBackgroundHighlight darken(@white, 10%)
@btnBorder darken(@white, 20%)
@btnPrimaryBackground @linkColor
@btnPrimaryBackgroundHighlight spin(@btnPrimaryBackground, 15%)
@btnInfoBackground #5bc0de
@btnInfoBackgroundHighlight #2f96b4
@btnSuccessBackground #62c462
@btnSuccessBackgroundHighlight 51a351
@btnWarningBackground lighten(@orange, 15%)
@btnWarningBackgroundHighlight @orange
@btnDangerBackground #ee5f5b
@btnDangerBackgroundHighlight #bd362f
@btnInverseBackground @gray
@btnInverseBackgroundHighlight @grayDarker

रूपाणि

@placeholderText @grayLight
@inputBackground @white
@inputBorder #ccc
@inputBorderRadius 3px
@inputDisabledBackground @grayLighter
@formActionsBackground #f5f5f5

अवस्थाएँ एवं अलर्ट बनाएँ

@warningText # ग09853
@warningBackground # f3edd2
@errorText # ख९४अ४८
@errorBackground # च२देदे
@successText # ४६८८४७
@successBackground # dff0d8 इति
@infoText # ३अ८७अद्
@infoBackground # घ९एडफ७

नवबर

@navbarHeight ४०px इति
@navbarBackground @grayDarker
@navbarBackgroundHighlight @grayDark
@navbarText @grayLight
@navbarLinkColor @grayLight
@navbarLinkColorHover @white
@navbarLinkColorActive @navbarLinkColorHover
@navbarLinkBackgroundHover transparent
@navbarLinkBackgroundActive @navbarBackground
@navbarSearchBackground lighten(@navbarBackground, 25%)
@navbarSearchBackgroundFocus @white
@navbarSearchBorder darken(@navbarSearchBackground, 30%)
@navbarSearchPlaceholderColor #ccc
@navbarBrandColor @navbarLinkColor

ड्रॉपडाउन्स्

@dropdownBackground @white
@dropdownBorder rgba(0,0,0,.2)
@dropdownLinkColor @grayDark
@dropdownLinkColorHover @white
@dropdownLinkBackgroundHover @linkColor
@@dropdownDividerTop #e5e5e5
@@dropdownDividerBottom @white

नायक इकाई

@heroUnitBackground @grayLighter
@heroUnitHeadingColor inherit
@heroUnitLeadColor inhereit

मिक्सिन के बारे में

मूलभूत मिक्सिन

मूलभूतं mixin मूलतः CSS इत्यस्य स्निपेट् कृते include अथवा partial भवति । ते CSS वर्ग इव लिखिताः सन्ति तथा च कुत्रापि आह्वयितुं शक्यन्ते।

  1. . तत्व { .
  2. . clearfix ();
  3. } इति ।

पैरामीटरिक मिक्सिन

पैरामीटर् मिक्सिन् मूलभूतमिक्सिन् इव भवति, परन्तु वैकल्पिकपूर्वनिर्धारितमूल्यानां सह पैरामीटर् (अतः नाम) अपि स्वीकुर्वति ।

  1. . तत्व { .
  2. . सीमा - त्रिज्या ( 4px );
  3. } इति ।

सहजतया स्वस्य योजयन्तु

Bootstrap इत्यस्य प्रायः सर्वे mixins mixins.less इत्यत्र संगृहीताः सन्ति, एषा अद्भुता उपयोगिता .less सञ्चिका अस्ति या भवन्तं toolkit मध्ये .less सञ्चिकासु कस्यापि मध्ये mixin इत्यस्य उपयोगं कर्तुं समर्थयति

अतः, अग्रे गत्वा विद्यमानानाम् उपयोगं कुर्वन्तु अथवा आवश्यकतानुसारं स्वस्य योजयितुं निःशङ्कं भवन्तु।

मिक्सिन शामिल हैं

उपयोगिताएँ

मिक्सिन् पैरामीटर् प्रयोगः
.clearfix() न कश्चित् अन्तः प्लवकानि स्पष्टीकर्तुं कस्मिन् अपि मातापितरं योजयन्तु
.tab-focus() न कश्चित् Webkit फोकस शैली तथा गोल Firefox outline प्रयोजयन्तु
.center-block() न कश्चित् Auto center एक ब्लॉक-स्तरीय तत्व का उपयोग करते हुएmargin: auto
.ie7-inline-block() न कश्चित् display: inline-blockIE7 समर्थनं प्राप्तुं नियमितस्य अतिरिक्तं उपयोगं कुर्वन्तु
.size() @height @width एकस्मिन् रेखायां शीघ्रं ऊर्ध्वतां विस्तारं च सेट् कुर्वन्तु
.square() @size Builds on .size() to set the width and height as same value
.opacity() @opacity Set, in whole numbers, the opacity percentage (e.g., "50" or "75")

Forms

Mixin Parameters Usage
.placeholder() @color: @placeholderText Set the placeholder text color for inputs

Typography

Mixin Parameters Usage
#font > #family > .serif() none Make an element use a serif font stack
#font > #family > .sans-serif() none Make an element use a sans-serif font stack
#font > #family > .monospace() none Make an element use a monospace font stack
#font > .shorthand() @size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight Easily set font size, weight, and leading
#font > .serif() @size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight Set font family to serif, and control size, weight, and leading
#font > .sans-serif() @size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight Set font family to sans-serif, and control size, weight, and leading
#font > .monospace() @size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight Set font family to monospace, and control size, weight, and leading

Grid system

Mixin Parameters Usage
.container-fixed() none Create a horizontally centered container for holding your content
#grid > .core() @gridColumnWidth, @gridGutterWidth Generate a pixel grid system (container, row, and columns) with n columns and x pixel wide gutter
#grid > .fluid() @fluidGridColumnWidth, @fluidGridGutterWidth Generate a percent grid system with n columns and x % wide gutter
#grid > .input() @gridColumnWidth, @gridGutterWidth Generate the pixel grid system for input elements, accounting for padding and borders
.makeColumn @columns: 1, @offset: 0 Turn any div into a grid column without the .span* classes

CSS3 properties

Mixin Parameters Usage
.border-radius() @radius Round the corners of an element. Can be a single value or four space-separated values
.box-shadow() @shadow Add a drop shadow to an element
.transition() @transition Add CSS3 transition effect (e.g., all .2s linear)
.rotate() @degrees Rotate an element n degrees
.scale() @ratio Scale an element to n times its original size
.translate() @x, @y Move an element on the x and y planes
.background-clip() @clip Crop the background of an element (useful for border-radius)
.background-size() @size Control the size of background images via CSS3
.box-sizing() @boxmodel Change the box model for an element (e.g., border-box for a full-width input)
.user-select() @select Control cursor selection of text on a page
.backface-visibility() @visibility: visible Prevent flickering of content when using CSS 3D transforms
.resizable() @direction: both Make any element resizable on the right and bottom
.content-columns() @columnCount, @columnGap: @gridGutterWidth Make the content of any element use CSS3 columns
.hyphens() @mode: auto CSS3 hyphenation when you want it (includes word-wrap: break-word)

Backgrounds and gradients

Mixin Parameters Usage
#translucent > .background() @color: @white, @alpha: 1 Give an element a translucent background color
#translucent > .border() @color: @white, @alpha: 1 Give an element a translucent border color
#gradient > .vertical() @startColor, @endColor Create a cross-browser vertical background gradient
#gradient > .horizontal() @startColor, @endColor Create a cross-browser horizontal background gradient
#gradient > .directional() @startColor, @endColor, @deg Create a cross-browser directional background gradient
#gradient > .vertical-three-colors() @startColor, @midColor, @colorStop, @endColor Create a cross-browser three-color background gradient
#gradient > .radial() @innerColor, @outerColor Create a cross-browser radial background gradient
#gradient > .striped() @color, @angle Create a cross-browser striped background gradient
#gradientBar() @primaryColor, @secondaryColor Used for buttons to assign a gradient and slightly darker border
Note: If you're submitting a pull request to GitHub with modified CSS, you must recompile the CSS via any of these methods.

Tools for compiling

Node with makefile

Install the LESS command line compiler, JSHint, Recess, and uglify-js globally with npm by running the following command:

$ npm install -g less jshint recess uglify-js

Once installed just run make from the root of your bootstrap directory and you're all set.

Additionally, if you have watchr installed, you may run make watch to have bootstrap automatically rebuilt every time you edit a file in the bootstrap lib (this isn't required, just a convenience method).

Command line

Install the LESS command line tool via Node and run the following command:

$ lessc ./less/bootstrap.less > bootstrap.css

Be sure to include --compress in that command if you're trying to save some bytes!

Javascript

Download the latest Less.js and include the path to it (and Bootstrap) in the <head>.

<link rel="stylesheet/less" href="/path/to/bootstrap.less">
<script src="/path/to/less.js"></script>

To recompile the .less files, just save them and reload your page. Less.js compiles them and stores them in local storage.

Unofficial Mac app

The unofficial Mac app watches directories of .less files and compiles the code to local files after every save of a watched .less file.

If you like, you can toggle preferences in the app for automatic minifying and which directory the compiled files end up in.

More Mac apps

Crunch

Crunch is a great looking LESS editor and compiler built on Adobe Air.

CodeKit

Created by the same guy as the unofficial Mac app, CodeKit is a Mac app that compiles LESS, SASS, Stylus, and CoffeeScript.

Simpless

Mac, Linux, and PC app for drag and drop compiling of LESS files. Plus, the source code is on GitHub.