
- Bootstrap 教程
- Bootstrap - 首頁
- Bootstrap - 概述
- Bootstrap - 環境設定
- Bootstrap - RTL
- Bootstrap - CSS 變數
- Bootstrap - 色彩模式
- Bootstrap 佈局
- Bootstrap - 斷點
- Bootstrap - 容器
- Bootstrap - 網格系統
- Bootstrap - 列
- Bootstrap - 間距
- Bootstrap - 實用程式
- Bootstrap - CSS 網格
- Bootstrap 元件
- Bootstrap - 手風琴
- Bootstrap - 警報
- Bootstrap - 徽章
- Bootstrap - 麵包屑
- Bootstrap - 按鈕
- Bootstrap - 按鈕組
- Bootstrap - 卡片
- Bootstrap - 走馬燈
- Bootstrap - 關閉按鈕
- Bootstrap - 摺疊
- Bootstrap - 下拉選單
- Bootstrap - 列表組
- Bootstrap - 模態框
- Bootstrap - 導航欄
- Bootstrap - 導航和選項卡
- Bootstrap - 側邊欄
- Bootstrap - 分頁
- Bootstrap - 佔位符
- Bootstrap - 氣泡提示
- Bootstrap - 進度條
- Bootstrap - 滾動偵聽
- Bootstrap - 載入動畫
- Bootstrap - 吐司提示
- Bootstrap - 工具提示
- Bootstrap 表單
- Bootstrap - 表單
- Bootstrap - 表單控制元件
- Bootstrap - 選擇框
- Bootstrap - 複選框和單選按鈕
- Bootstrap - 範圍滑塊
- Bootstrap - 輸入組
- Bootstrap - 浮動標籤
- Bootstrap - 佈局
- Bootstrap - 驗證
- Bootstrap 輔助類
- Bootstrap - 清除浮動
- Bootstrap - 顏色和背景
- Bootstrap - 彩色連結
- Bootstrap - 聚焦環
- Bootstrap - 圖示連結
- Bootstrap - 定位
- Bootstrap - 比例
- Bootstrap - 堆疊
- Bootstrap - 拉伸連結
- Bootstrap - 文字截斷
- Bootstrap - 垂直線
- Bootstrap - 視覺隱藏
- Bootstrap 實用程式
- Bootstrap - 背景
- Bootstrap - 邊框
- Bootstrap - 顏色
- Bootstrap - 顯示
- Bootstrap - Flexbox
- Bootstrap - 浮動
- Bootstrap - 互動
- Bootstrap - 連結
- Bootstrap - 物件適應
- Bootstrap - 不透明度
- Bootstrap - 溢位
- Bootstrap - 定位
- Bootstrap - 陰影
- Bootstrap - 尺寸
- Bootstrap - 間距
- Bootstrap - 文字
- Bootstrap - 垂直對齊
- Bootstrap - 可見性
- Bootstrap 演示
- Bootstrap - 網格演示
- Bootstrap - 按鈕演示
- Bootstrap - 導航演示
- Bootstrap - 部落格演示
- Bootstrap - 滑塊演示
- Bootstrap - 走馬燈演示
- Bootstrap - 頁首演示
- Bootstrap - 頁尾演示
- Bootstrap - 英雄區演示
- Bootstrap - 特色演示
- Bootstrap - 側邊欄演示
- Bootstrap - 下拉選單演示
- Bootstrap - 列表組演示
- Bootstrap - 模態框演示
- Bootstrap - 徽章演示
- Bootstrap - 麵包屑演示
- Bootstrap - 超大標題演示
- Bootstrap - 粘性頁尾演示
- Bootstrap - 相簿演示
- Bootstrap - 登入演示
- Bootstrap - 定價演示
- Bootstrap - 結賬演示
- Bootstrap - 產品演示
- Bootstrap - 封面演示
- Bootstrap - 儀表盤演示
- Bootstrap - 粘性頁尾導航欄演示
- Bootstrap - 砌體佈局演示
- Bootstrap - 啟動模板演示
- Bootstrap - 相簿 RTL 演示
- Bootstrap - 結賬 RTL 演示
- Bootstrap - 走馬燈 RTL 演示
- Bootstrap - 部落格 RTL 演示
- Bootstrap - 儀表盤 RTL 演示
- Bootstrap 有用資源
- Bootstrap - 問答
- Bootstrap - 快速指南
- Bootstrap - 有用資源
- Bootstrap - 討論
Bootstrap - 浮動
本章討論實用程式類.float-*。
概述
.float 類用於控制元素在網格系統中的位置和對齊方式。
它主要與網格系統的列類一起使用,以建立響應式佈局。
.float 類有助於根據當前視口大小將元素向左或向右浮動,或停用浮動。
這些實用程式類使用與網格系統相同的視口斷點。
.float 實用程式類對 flex 專案沒有影響。
Bootstrap 中提供的.float 類如下
.float-start - 此類用於將元素在網格列中向左浮動。
.float-end - 此類用於將元素在網格列中向右浮動。
.float-none - 此類不會對元素應用任何浮動類。
讓我們看一個例子
示例
您可以使用編輯和執行選項編輯和嘗試執行此程式碼。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Float</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h4>Float utilities</h4> <div class="float-start"> <button class="btn btn-success">Float start (on left)</button> </div> <div class="float-end"> <button class="btn btn-primary">Float end (on right)</button> </div> <div class="float-none"> <button class="btn btn-warning">Float none</button> </div> </body> </html>
響應式
每個.float 值可以應用於所有響應式視口變體,例如sm、md、lg、xl 和xxl。
以下是所有支援的.float 類列表
.float_start
.float_end
.float_none
.float_sm_start
.float_sm_end
.float_sm_none
.float_md_start
.float_md_end
.float_md_none
.float_lg_start
.float_lg_end
.float_lg_none
.float_xl_start
.float_xl_end
.float_xl_none
.float_xxl_start
.float_xxl_end
.float_xxl_none
注意:請調整瀏覽器大小,以檢視文字的浮動效果。
讓我們看看這些實用程式類在各種視口上的示例
示例
您可以使用編輯和執行選項編輯和嘗試執行此程式碼。
<!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Float</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> </head> <body> <div class="container mt-3"> <h4><u>Responsive float utilities</u></h4> <div class="float-sm-start p-2 text-primary"> The text floats to the left when the screen size is small or wider. </div> <div class="float-md-end p-2 text-success"> The text floats to the right when the screen size is medium or wider. </div> <div class="float-lg-none p-2 text-danger"> The text does not float to the right when the screen size is large or wider. </div> <div class="float-xl-end p-2 text-info"> The text floats to the right when the screen size is extra large or wider. </div> </div> </body> </html>
廣告