Tùy chỉnh Bootstrap 4 với các biến Sass tích hợp mới của chúng tôi cho các tùy chọn kiểu chung để dễ dàng thay đổi chủ đề và thành phần Giới thiệuTrong Bootstrap 3, chủ đề chủ yếu được điều khiển bởi các phần ghi đè biến trong LESS, CSS tùy chỉnh và biểu định kiểu chủ đề riêng biệt mà chúng tôi đã đưa vào tệp // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 3 của mình. Với một số nỗ lực, người ta có thể thiết kế lại hoàn toàn giao diện của Bootstrap 3 mà không cần chạm vào các tệp cốt lõi. Bootstrap 4 cung cấp một cách tiếp cận quen thuộc nhưng hơi khácGiờ đây, chủ đề được thực hiện bằng các biến Sass, bản đồ Sass và CSS tùy chỉnh. Không có biểu định kiểu chủ đề chuyên dụng nào nữa; ngổ ngáoSử dụng các tệp Sass nguồn của chúng tôi để tận dụng các biến, bản đồ, mixin, v.v. cấu trúc tệpBất cứ khi nào có thể, hãy tránh sửa đổi các tệp cốt lõi của Bootstrap. Đối với Sass, điều đó có nghĩa là tạo biểu định kiểu của riêng bạn, nhập Bootstrap để bạn có thể sửa đổi và mở rộng nó. Giả sử bạn đang sử dụng trình quản lý gói như npm, bạn sẽ có cấu trúc tệp trông như thế này your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss
Nếu bạn đã tải xuống các tệp nguồn của chúng tôi và không sử dụng trình quản lý gói, bạn sẽ muốn thiết lập thủ công một cái gì đó tương tự với cấu trúc đó, giữ các tệp nguồn của Bootstrap tách biệt với các tệp nguồn của bạn your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss
nhập khẩuTrong // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 4 của bạn, bạn sẽ nhập các tệp Sass nguồn của Bootstrap. Bạn có hai lựa chọn. bao gồm tất cả Bootstrap hoặc chọn những phần bạn cần. Chúng tôi khuyến khích cách thứ hai, mặc dù lưu ý rằng có một số yêu cầu và sự phụ thuộc giữa các thành phần của chúng tôi. Bạn cũng sẽ cần bao gồm một số JavaScript cho các plugin của chúng tôi// Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap";
// Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid";
Với thiết lập đó, bạn có thể bắt đầu sửa đổi bất kỳ biến Sass và bản đồ nào trong // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 4 của mình. Bạn cũng có thể bắt đầu thêm các phần của Bootstrap vào phần // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 6 nếu cần. Chúng tôi khuyên bạn nên sử dụng ngăn xếp nhập đầy đủ từ tệp // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 7 của chúng tôi làm điểm xuất phát của bạnGiá trị mặc định của biếnMỗi biến Sass trong Bootstrap 4 bao gồm cờ // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 8 cho phép bạn ghi đè giá trị mặc định của biến trong Sass của riêng bạn mà không cần sửa đổi mã nguồn của Bootstrap. Sao chép và dán các biến nếu cần, sửa đổi giá trị của chúng và xóa cờ // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 8. Nếu một biến đã được gán, thì nó sẽ không được gán lại bởi các giá trị mặc định trong BootstrapBạn sẽ tìm thấy danh sách đầy đủ các biến của Bootstrap trong // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 0Ghi đè biến trong cùng một tệp Sass có thể xuất hiện trước hoặc sau các biến mặc định. Tuy nhiên, khi ghi đè lên các tệp Sass, phần ghi đè của bạn phải đến trước khi bạn nhập tệp Sass của Bootstrap Đây là một ví dụ thay đổi // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 1 và // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 2 khi nhập và biên dịch Bootstrap qua npmyour-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 4Lặp lại nếu cần cho bất kỳ biến nào trong Bootstrap, bao gồm các tùy chọn chung bên dưới Bản đồ và vòng lặpBootstrap 4 bao gồm một số bản đồ Sass, các cặp giá trị chính giúp tạo các họ CSS liên quan dễ dàng hơn. Chúng tôi sử dụng bản đồ Sass cho màu sắc, điểm ngắt lưới và hơn thế nữa. Giống như các biến Sass, tất cả các bản đồ Sass bao gồm cờ // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 8 và có thể được ghi đè và mở rộngMột số bản đồ Sass của chúng tôi được hợp nhất thành những bản đồ trống theo mặc định. Điều này được thực hiện để cho phép dễ dàng mở rộng bản đồ Sass nhất định, nhưng phải trả giá bằng việc loại bỏ các vật phẩm khỏi bản đồ khó khăn hơn một chút sửa đổi bản đồĐể sửa đổi màu hiện có trong bản đồ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 của chúng tôi, hãy thêm phần sau vào tệp Sass tùy chỉnh của bạnyour-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 7Thêm vào bản đồĐể thêm màu mới vào // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4, hãy thêm khóa và giá trị mớiyour-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 9Xóa khỏi bản đồĐể xóa màu khỏi // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 hoặc bất kỳ bản đồ nào khác, hãy sử dụng // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 7. Xin lưu ý rằng bạn phải chèn nó vào giữa các yêu cầu và tùy chọn của chúng tôiyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 2Các phím bắt buộcBootstrap giả định sự hiện diện của một số khóa cụ thể trong bản đồ Sass khi chúng tôi sử dụng và tự mở rộng các khóa này. Khi bạn tùy chỉnh các bản đồ đi kèm, bạn có thể gặp lỗi khi sử dụng khóa của bản đồ Sass cụ thể Ví dụ: chúng tôi sử dụng các khóa // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 8, // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 9 và your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 40 từ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 cho các liên kết, nút và trạng thái biểu mẫu. Việc thay thế các giá trị của các khóa này sẽ không có vấn đề gì, nhưng việc xóa chúng có thể gây ra sự cố biên dịch Sass. Trong những trường hợp này, bạn sẽ cần sửa đổi mã Sass sử dụng các giá trị đóChức năngBootstrap sử dụng một số chức năng Sass, nhưng chỉ một tập hợp con được áp dụng cho chủ đề chung. Chúng tôi đã bao gồm ba chức năng để nhận các giá trị từ bản đồ màu your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 7Những thứ này cho phép bạn chọn một màu từ bản đồ Sass giống như cách bạn sử dụng biến màu từ v3 your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 8Chúng tôi cũng có một chức năng khác để lấy một mức độ màu cụ thể từ bản đồ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4. Các giá trị mức âm sẽ làm sáng màu, trong khi các mức cao hơn sẽ tối hơnyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 0Trong thực tế, bạn sẽ gọi hàm và truyền vào hai tham số. tên của màu từ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 (e. g. , chính hoặc nguy hiểm) và cấp sốyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 1Các hàm bổ sung có thể được thêm vào trong tương lai hoặc Sass tùy chỉnh của riêng bạn để tạo các hàm cấp độ cho các bản đồ Sass bổ sung hoặc thậm chí là một bản đồ chung nếu bạn muốn dài dòng hơn Độ tương phản màuMột chức năng bổ sung mà chúng tôi đưa vào Bootstrap là chức năng tương phản màu, your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 44. Nó sử dụng không gian màu YIQ để tự động trả về màu tương phản sáng (your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 45) hoặc tối (your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 46) dựa trên màu cơ bản đã chỉ định. Hàm này đặc biệt hữu ích cho các mixin hoặc vòng lặp mà bạn đang tạo nhiều lớpVí dụ: để tạo các mẫu màu từ bản đồ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 của chúng tôiyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 2Nó cũng có thể được sử dụng cho các nhu cầu tương phản một lần your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 3Bạn cũng có thể chỉ định một màu cơ bản với các chức năng bản đồ màu của chúng tôi your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 4tùy chọn sassTùy chỉnh Bootstrap 4 với tệp biến tùy chỉnh được tích hợp sẵn của chúng tôi và dễ dàng chuyển đổi các tùy chọn CSS toàn cầu với biến your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 48 Sass mới. Ghi đè giá trị của một biến và biên dịch lại với your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 49 nếu cầnBạn có thể tìm và tùy chỉnh các biến này cho các tùy chọn toàn cầu chính trong tệp // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 0 của BootstrapVariableValuesDescriptionyour-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 71your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 72 (mặc định) hoặc bất kỳ giá trị nào > 0Chỉ định giá trị bộ đệm mặc định để tạo các tiện ích bộ đệm của chúng tôi theo chương trình. your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 73your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 (mặc định) hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75Bật kiểu your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 76 được xác định trước trên các thành phần khác nhau. your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 77your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75 (mặc định) Cho phép các kiểu your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 90 được xác định trước trên các thành phần khác nhau. your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 91your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75 (mặc định) Cho phép chuyển màu được xác định trước thông qua kiểu your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 94 trên các thành phần khác nhau. your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 95your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 (mặc định) hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75Bật các your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 98 được xác định trước trên các thành phần khác nhau. your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 99your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75 (mặc định)Không dùng nữayour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 22your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 (mặc định) hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75Cho phép tạo các lớp CSS cho hệ thống lưới (e. g. , your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 25, your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 26, your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 27, v.v. ). your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 28your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 (mặc định) hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75Bật dấu mũ phần tử giả trên your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 71. your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 72your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 74 (mặc định) hoặc your-project/
├── scss
│ └── custom.scss
└── node_modules/
└── bootstrap
├── js
└── scss 75Kích hoạt các kiểu để tối ưu hóa việc in ấnMàuNhiều thành phần và tiện ích khác nhau của Bootstrap được xây dựng thông qua một loạt các màu được xác định trong bản đồ Sass. Bản đồ này có thể được lặp lại trong Sass để nhanh chóng tạo ra một loạt các bộ quy tắc Đủ màu sắcTất cả các màu có sẵn trong Bootstrap 4, có sẵn dưới dạng biến Sass và bản đồ Sass trong tệp // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 0. Điều này sẽ được mở rộng trong các bản phát hành nhỏ tiếp theo để thêm các sắc thái bổ sung, giống như những gì chúng tôi đã đưa vàoĐây là cách bạn có thể sử dụng chúng trong Sass của mình your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 5Các lớp tiện ích màu cũng có sẵn để thiết lập // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 2 và // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 1Trong tương lai, chúng tôi sẽ hướng đến việc cung cấp bản đồ Sass và các biến cho các sắc thái của từng màu như chúng tôi đã thực hiện với các màu thang độ xám bên dưới màu sắc chủ đềChúng tôi sử dụng một tập hợp con của tất cả các màu để tạo một bảng màu nhỏ hơn để tạo bảng phối màu, cũng có sẵn dưới dạng biến Sass và bản đồ Sass trong tệp // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 0 của Bootstrapsmàu xámMột tập hợp mở rộng các biến màu xám và bản đồ Sass trong // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 0 cho các sắc thái xám nhất quán trong dự án của bạnTrong vòng ________ 50, bạn sẽ tìm thấy các biến màu Bootstrap và bản đồ Sass. Đây là một ví dụ về bản đồ your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 81 Sassyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 6Thêm, xóa hoặc sửa đổi các giá trị trong bản đồ để cập nhật cách chúng được sử dụng trong nhiều thành phần khác. Thật không may, tại thời điểm này, không phải mọi thành phần đều sử dụng bản đồ Sass này. Các bản cập nhật trong tương lai sẽ cố gắng cải thiện điều này. Cho đến lúc đó, hãy lên kế hoạch sử dụng các biến your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 82 và bản đồ Sass nàyCác thành phầnNhiều thành phần và tiện ích của Bootstrap được xây dựng với các vòng lặp your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 83 lặp lại trên bản đồ Sass. Điều này đặc biệt hữu ích để tạo các biến thể của một thành phần bằng // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 của chúng tôi và tạo các biến thể đáp ứng cho từng điểm dừng. Khi bạn tùy chỉnh các bản đồ Sass này và biên dịch lại, bạn sẽ tự động thấy các thay đổi của mình được phản ánh trong các vòng lặp nàysửa đổiNhiều thành phần của Bootstrap được xây dựng với cách tiếp cận lớp sửa đổi cơ sở. Điều này có nghĩa là phần lớn kiểu dáng được chứa trong một lớp cơ sở (e. g. , your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 85) trong khi các biến thể phong cách được giới hạn trong các lớp sửa đổi (e. g. , your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 86). Các lớp công cụ sửa đổi này được xây dựng từ bản đồ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 để tùy chỉnh số lượng và tên của các lớp công cụ sửa đổi của chúng tôiDưới đây là hai ví dụ về cách chúng tôi lặp qua bản đồ // Custom.scss
// Option B: Include parts of Bootstrap
// Required
@import "../node_modules/bootstrap/scss/functions";
@import "../node_modules/bootstrap/scss/variables";
@import "../node_modules/bootstrap/scss/mixins";
// Optional
@import "../node_modules/bootstrap/scss/reboot";
@import "../node_modules/bootstrap/scss/type";
@import "../node_modules/bootstrap/scss/images";
@import "../node_modules/bootstrap/scss/code";
@import "../node_modules/bootstrap/scss/grid"; 4 để tạo các công cụ sửa đổi cho thành phần your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 89 và tất cả các tiện ích nền your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 00 của chúng tôiyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 7Phản ứng nhanh nhẹnCác vòng lặp Sass này cũng không giới hạn ở các bản đồ màu. Bạn cũng có thể tạo các biến thể đáp ứng của các thành phần hoặc tiện ích của mình. Lấy ví dụ về các tiện ích căn chỉnh văn bản đáp ứng của chúng tôi, nơi chúng tôi trộn một vòng lặp your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 83 cho bản đồ your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 02 Sass với một truy vấn phương tiện bao gồmyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 8Nếu bạn cần sửa đổi your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 02 của mình, những thay đổi của bạn sẽ áp dụng cho tất cả các vòng lặp lặp lại trên bản đồ đóbiến CSSBootstrap 4 bao gồm khoảng hai chục thuộc tính tùy chỉnh CSS (biến) trong CSS được biên dịch của nó. Những thứ này cung cấp khả năng truy cập dễ dàng vào các giá trị thường được sử dụng như màu chủ đề, điểm dừng và ngăn xếp phông chữ chính của chúng tôi khi làm việc trong Trình kiểm tra của trình duyệt, hộp cát mã hoặc nguyên mẫu chung biến có sẵnDưới đây là các biến chúng tôi đưa vào (lưu ý rằng ______204 là bắt buộc). Chúng nằm trong tệp your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 05 của chúng tôiyour-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 9ví dụCác biến CSS cung cấp tính linh hoạt tương tự như các biến của Sass, nhưng không cần biên dịch trước khi được cung cấp cho trình duyệt. Ví dụ: ở đây chúng tôi đang đặt lại phông chữ và kiểu liên kết của trang bằng các biến CSS // Custom.scss
// Option A: Include all of Bootstrap
@import "../node_modules/bootstrap/scss/bootstrap"; 0Biến điểm dừngMặc dù ban đầu chúng tôi đã bao gồm các điểm dừng trong các biến CSS của mình (e. g. , your-project/
├── scss
│ └── custom.scss
└── bootstrap/
├── js
└── scss 06), chúng không được hỗ trợ trong truy vấn phương tiện, nhưng chúng vẫn có thể được sử dụng trong bộ quy tắc trong truy vấn phương tiện. Các biến điểm dừng này vẫn còn trong CSS đã biên dịch để tương thích ngược với điều kiện chúng có thể được JavaScript sử dụng. |