目錄
CSS Grid是什麼?
首頁 web前端 css教學 CSS Grid和Bootstrap之間的區別

CSS Grid和Bootstrap之間的區別

Sep 08, 2023 pm 05:17 PM

CSS Grid和Bootstrap之间的区别

大多數情況下,我們會在需要嚴格佈局要求並希望內容按照這些要求在頁面上流動的情況下使用CSS Grid。

Bootstrap的網格系統是基於CSS Flexbox佈局系統,而CSS Grid則受到基於列印的id的影響。 Bootstrap是CSS Grid的直接競爭對手,兩個框架的網格佈局系統可以進行重要的比較。

如果我們希望在行或列方向上對佈局進行控制,那麼應該使用Bootstrap提供的基於Flexbox的網格。另一方面,如果您希望在行和列上都對佈局進行控制,則應該使用CSS Grid作為解決方案。

CSS Grid是什麼?

一系列相交的垂直和水平線被理解為網格。 CSS3可以使用網格佈局將頁面分割為不同的部分。

網格屬性提供了一個基於行和列的網格佈局系統。它使得在網頁設計中不再需要元素的佈局和浮動。網格佈局提供了一種使用CSS而不是HTML來建立網格結構的方法。

CSS Grid佈局在將頁面分割為關鍵部分或在HTML基於原始控制項的許多元件之間建立大小、位置和層次關係方面特別有效。

請看以下範例

<div class="grid_container">
   <div class="grid_items">01</div>
   <div class="grid_items">02</div>
   <div class="grid_items">03</div>
   <div class="grid_items">04</div>
   <div class="grid_items">05</div>
   <div class="grid_items">06</div>
   <div class="grid_items">07</div>
   <div class="grid_items">08</div>
   <div class="grid_items">09</div>
</div>
登入後複製

It functions in a manner that is similar to that of a table in that it lets the user arrange the items into rows and columns . However, in contrast to tables, the CSS grid makes designing a layout really simple. By using the grid-template-rows and grid-template-columns attributes, we are able to specify the columns and rows that appear on the grify the columns and rows that appear on the grify.

##What is Bootstrap?

When it comes to designing a website that is responsive and user-friendly on mobile devices, the HTML, CSS, and JavaScript framework known as Bootstrap is by ularfar the most option. It does not cost anything to download or make use of the tool. It is a front-end framework that makes the process of developing websites simpler and more efficient.

contains websites simpler and more efficient.

contains design templates 1on CSS for typography, forms, buttons, tables, navigation, modals, picture carousels, and a lot of other things. In addition to that, it supports plug-ins written in JavaScript. It makes it easier for you to builive signs thatsareive de you to

What is Bootstrap Grid?

The grid structure that Bootstrap uses is responsive, which means that the columns will rearrange themselves based on the size of the screen − If the material is structured , it may appear better on a large screen; yet, if the content elements are piled on top of each other, it may look better on a tiny screen.

There are four classes included in grstra
  • xs

    (for phones − screens less than 768px wide)
  • sm

    (for tablets − screens equal to or greater than 768px wide)
  • md

    (for small laptops − screens equal to or greater than 992px#ide)

  • ##4
  • lg

    (for laptops and desktops − screens equal to or greater than 1200px wide)
  • #Take a look at the following
  • Example
  • <div class="row">
       <div class="col-xs-9 col-md-7">col-xs-9 and col-md-7</div>
       <div class="col-xs-3 col-md-5">col-xs-3 and col-md-5</div>
    </div>
    
    <div class="row">
       <div class="col-xs-6 col-md-10">col-xs-6 and col-md-10</div>
       <div class="col-xs-6 col-md-2">col-xs-6 and col-md-2</div>
    </div>
    
    <div class="row">
       <div class="col-xs-6">col-xs-6</div>
       <div class="col-xs-6">col-xs-6</div>
    </div>
    登入後複製
  • 為了適當的對齊和填充,行必須包含在一個".container"(固定寬度)或".container-fluid"(全寬)中。

  • 透過使用行建立水平列組。

  • 只有列可以是瞬時的,內容要放在列內。

  • 可以使用預先定義的類別(如 ".row" 和 ".col-sm-4")快速建立網格佈局。

    列之間的填充創建了間隙(列之間的空間)。在 ".rows" 上使用負邊距來抵銷第一列和最後一列的填滿。 ############透過定義要跨越的列數(可用的12個選項)來建立網格列。例如,三個等寬的欄位可以由三個 ".col-sm-4" 表示。 ############由於列寬以百分比表示,它們始終是靈活的,並且與其父元素成比例。 ############CSS Grid 和 Bootstrap 的差異######下表突顯了 CSS Grid 和 Bootstrap 之間的主要差異 -#####CSS GridBootstrap標記它具有更清晰和更易讀的標記。網格的佈局不是在HTML中完成,而是在CSS中完成。 為了建立佈局,每行都需要一個div標籤,並在每個div元素中定義類別層級。這使得程式碼變得更長。 響應式即使HTML不變,只需新增各種媒體查詢並描述每個HTML元素的網格佈局即可修改CSS。 使用已建立的類別層級,可以獨立設計各種不同裝置尺寸的內容區域佈局。然而,隨著類別的數量增加,標記會變得更加繁瑣。 頁面載入速度得到了絕大多數瀏覽器和版本的強力支援。無需下載任何內容,網站載入速度更快。 由於需要下載樣式表的附屬文件,網站載入速度較慢。 列限制它提供了一個沒有列數限制的靈活佈局。因此,擁有任意數量的列並不困難。 由於網格被分成12列,無法實現不總和為12的佈局。
    比較基礎
    結論

    使用Bootstrap需要寫更多HTML,而使用CSS Grid則需要寫更多CSS。

    根據設計要求,使用Bootstrap可能不是一個選擇。對於較簡單的佈局,Bootstrap是一個簡單的選擇,可以在合理的時間內讓您上手。

    請記住,Bootstrap不僅僅是一個網格系統;它是一個包含了預定義類別的全面前端工具包,用於模態框、工具提示、彈出框、進度條等等。要使用CSS Grid獲得相同的結果,您需要使用JS或JQuery編寫檔案。

    以上是CSS Grid和Bootstrap之間的區別的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1666
14
CakePHP 教程
1425
52
Laravel 教程
1323
25
PHP教程
1272
29
C# 教程
1251
24
使Sass更快的概念證明 使Sass更快的概念證明 Apr 16, 2025 am 10:38 AM

在一個新項目開始時,Sass彙編發生在眼睛的眨眼中。感覺很棒,尤其是當它與browsersync配對時,它重新加載

靜態表單提供商的比較 靜態表單提供商的比較 Apr 16, 2025 am 11:20 AM

讓我們嘗試在這裡造成一個術語:“靜態表單提供商”。你帶上html

每周平台新聞:HTML加載屬性,主要的ARIA規格以及從iframe轉移到Shadow dom 每周平台新聞:HTML加載屬性,主要的ARIA規格以及從iframe轉移到Shadow dom Apr 17, 2025 am 10:55 AM

在本週的平台新聞綜述中,Chrome引入了一個用於加載的新屬性,Web開發人員的可訪問性規範以及BBC Move

與部分元素的交易 與部分元素的交易 Apr 12, 2025 am 11:39 AM

同一天發表了兩篇文章:

帶有HTML對話框元素的一些動手 帶有HTML對話框元素的一些動手 Apr 16, 2025 am 11:33 AM

這是我第一次查看HTML元素。我已經意識到了一段時間,但是尚未將其旋轉。它很酷,

我們如何標記Google字體並創建Goofonts.com 我們如何標記Google字體並創建Goofonts.com Apr 12, 2025 pm 12:02 PM

Goofonts是由開發人員和設計師丈夫簽名的附帶項目,它們都是版式的忠實擁護者。我們一直在標記Google

多腳步滑塊:一般案例 多腳步滑塊:一般案例 Apr 12, 2025 am 10:52 AM

這個兩部分系列的第一部分詳細介紹了我們如何獲得兩次跑步的滑塊。現在,我們&#039;

'訂閱播客”鏈接應在哪裡? '訂閱播客”鏈接應在哪裡? Apr 16, 2025 pm 12:04 PM

有一段時間,iTunes是播客中的大狗,因此,如果您將“訂閱播客”鏈接到喜歡:

See all articles