
- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 內聯塊
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 位置
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 平移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - Z 索引
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪裁
- CSS - 書寫模式
- CSS - Unicode 雙向
- CSS - min-content
- CSS - 全部
- CSS - 內嵌
- CSS - 隔離
- CSS - 滾動溢位
- CSS - Justify Items
- CSS - Justify Self
- CSS - 製表符大小
- CSS - 指標事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大塊級尺寸
- CSS - 最小塊級尺寸
- CSS - 混合模式
- CSS - 最大內聯尺寸
- CSS - 最小內聯尺寸
- CSS - 偏移量
- CSS - 口音色
- CSS - 使用者選擇
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 圖層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - !important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 2D 變換
- CSS - 3D 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - 調整大小
CSS 的 resize 屬性允許使用者調整元素的大小,可以是垂直方向、水平方向、兩個方向或都不調整,具體取決於指定的值。
Resize 屬性在網頁元素的右下角新增一個手柄。此手柄允許使用者點選並拖動以更改元素的大小,使其根據自己的喜好變大或變小。
本章將介紹 resize 屬性的使用。
可能的值
none - 不允許使用者調整元素的大小。這是預設值。
vertical - 使用者可以垂直調整元素的大小。
horizontal - 使用者可以水平調整元素的大小。
both - 使用者可以水平和垂直調整元素的大小。
block - 使用者可以根據書寫模式和方向值在塊方向(水平或垂直)調整元素的大小。
inline - 使用者可以根據書寫模式和方向值在內聯方向(水平或垂直)調整元素的大小。
block 和 inline 屬性僅在 Firefox 和 Safari 瀏覽器中受支援。
應用於
溢位(overflow)屬性不為 visible 的元素,以及可選地表示影像或影片的替換元素和 iframe。
語法
resize: none | vertical | horizontal| both;
CSS resize - none 值
以下示例演示了將 CSS resize 屬性設定為 none 值的使用。在這裡,我們看到使用者無法在任何方向調整元素的大小。resize: none 是預設值。
<html> <head> <style> textarea { background-color: #e7ef0e; color: #ee2610; resize: none; overflow: auto; height: 150px; width: 250px; } </style> </head> <body> <textarea>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.</textarea> </body> </html>
CSS resize - vertical 值
以下示例演示了將 CSS resize 屬性設定為 vertical 的使用。在這裡,我們看到使用者可以透過拖動右下角來垂直調整 <div> 元素的高度。
<html> <head> <style> div { background-color: #e7ef0e; color: #ee2610; resize: vertical; overflow: auto; height: 150px; width: 250px; } </style> </head> <body> <h3>Click and drag the bottom-right corner to change the size of an element vertically.</h3> <div> <h2 style="color: #0f5e02; text-align: center;">Tutorialspoint</h2> There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. </div> </body> </html>
CSS resize - horizontal 值
以下示例演示了將 CSS resize 屬性設定為 horizontal 的使用。在這裡,我們看到使用者可以透過拖動右下角來水平調整 <div> 元素的寬度。
<html> <head> <style> div { background-color: #e7ef0e; color: #ee2610; resize: horizontal; overflow: auto; height: 150px; width: 250px; } </style> </head> <body> <h3>Click and drag the bottom-right corner to change the size of an element horizontally.</h3> <div> <h2 style="color: #0f5e02; text-align: center;">Tutorialspoint</h2> There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the internet. </div> </body> </html>
CSS resize - both 值
以下示例演示了將 CSS resize 屬性設定為 both 的使用。在這裡,我們看到使用者可以水平和垂直調整元素的大小。
<html> <head> <style> div { background-color: #e7ef0e; color: #ee2610; resize: both; overflow: auto; height: 150px; width: 250px; } </style> </head> <body> <h3>Click and drag the bottom-right corner to change the size of an element vertically and horizontally.</h3> <div> <h2 style="color: #0f5e02; text-align: center;">Tutorialspoint</h2> There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. </div> </body> <html>
CSS resize - inherit 值
以下示例演示了在子元素上將 CSS resize 屬性設定為 inherit 的使用。在這裡,我們看到它將具有與其父元素相同的調整大小行為。
<html> <head> <style> .my-box1 { background-color: #e7ef0e; color: #ee2610; resize: vertical; overflow: auto; height: 150px; width: 250px; } .my-box2 { resize: inherit; } </style> </head> <body> <h3>Click and drag the bottom-right corner to change the size of an element.</h3> <div class="my-box1"> <div class="my-box2"> <h2 style="color: #0f5e02; text-align: center;">Tutorialspoint</h2> There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. </div> </div> </body> </html>
CSS resize - 任意元素
可以建立一個可調整大小的 <div> 容器,其中包含一個可調整大小的 <p>(段落)元素,使用者可以點選並拖動右下角來更改容器和段落的大小。以下示例演示了此行為。
<html> <head> <style> .my-box { background-color: #e7ef0e; color: #ee2610; resize: both; overflow: scroll; border: 2px solid black; } div { height: 250px; width: 250px; } p { height: 150px; width: 150px; } </style> </head> <body> <h3>Click and drag the bottom-right corner to change the size of an element.</h3> <div class="my-box"> <h2 style="color: #0f5e02; text-align: center;">Tutorialspoint</h2> <p class="my-box"> There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you ar going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.</p> </div> </body> </html>