Công ty thiết kế website chuẩn SEO Web Mới
Tìm kiếm
Công ty thiết kế website chuẩn SEO Web Mới

Thuộc tính outline trong CSS

Thuộc tính outline trong CSS dùng để kẻ đường viền nằm bên ngoài border của phần tử HTML input và textarea, chi tiết như nào hãy cùng chúng tôi phân tích:

Thuộc tính outline trong CSS

Thuộc tính outline trong CSS

Chức năng của Thuộc tính outline trong CSS

Thuộc tính outline trong CSS dùng để kẻ đường viền nằm bên ngoài border của phần tử HTML input và textarea.

Cú pháp của Thuộc tính outline trong CSS

outline: kichthuoc kieu mau;

kichthuoc: ví dụ 1px hay 5px, quy định kích thước đường viền.

kieu: Kiểu outline như dotted, dashed, quy định loại đường viền, là những giá trị của thuộc tính outline.

mau: Màu sắc đường viền, ví dụ red, blue.

Các giá trị của Thuộc tính outline trong CSS

dotted: Đường viền hình tròn.

dashed: Đường viền nét đứt.

double: có 2 đường viền cùng màu cách nhau bởi khoảng trắng.

ridge: Đường viền phối khung màu.

solid: Đường viền nét liền.

groove:  Đường viền phối khung màu nhưng ngược màu với ridge.

inset:: Chỉ định đường viền chèn 3D, phối thêm một màu so với màu được đưa vào.

outset: Chỉ định đường viền chèn 3D, phối thêm một màu so với màu được đưa vào, ngược với inset.

none: Không có đường viền và khi để chuột vào ô thì cũng không hiện đường viền gì hết.

mặc định: Mặc định không để css outline thì khi để chuột vào sẽ hiện đường viền màu xám.

initial: Đưa giá trị của thuộc tính outline về giá trị mặc định.

inherit: Kế thừa thuộc tính outline từ phần tử cha.

Code Thuộc tính outline trong CSS

<!DOCTYPE html>
<html>
<head>
<title>Code Thuộc tính outline trong CSS</title>
<style>
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
input{width:100%; height:35px; border:3px solid red; float:left; margin-bottom:20px}
textarea{width:100%; height:50px; border:3px solid red; float:left; margin-bottom:20px}
</style>
</head>
<body>
<h1>Code Thuộc tính outline trong CSS</h1>

<!--dotted-->
<input style="outline: 5px dotted green;" type="text" placeholder="outline: 5px dotted green;">
<textarea style="outline: 5px dotted green;" placeholder="outline: 5px dotted green;"></textarea>

<!--dashed-->
<input style="outline: 4px dashed blue;" type="text" placeholder="outline: 4px dashed blue;">
<textarea style="outline: 4px dashed blue;" placeholder="outline: 4px dashed blue;"></textarea>

<!--double-->
<input style="outline: 5px double green;" type="text" placeholder="outline: 5px double green;">
<textarea style="outline: 5px double green;" placeholder="outline: 5px double green;"></textarea>

<!--ridge-->
<input style="outline: 5px ridge green;" type="text" placeholder="outline: 5px ridge green;">
<textarea style="outline: 5px ridge green;" placeholder="outline: 5px ridge green;"></textarea>

<!--solid-->
<input style="outline: 5px solid green;" type="text" placeholder="outline: 5px solid green;">
<textarea style="outline: 5px solid green;" placeholder="outline: 5px solid green;"></textarea>

<!--groove-->
<input style="outline: 5px groove green;" type="text" placeholder="outline: 5px groove green;">
<textarea style="outline: 5px groove green;" placeholder="outline: 5px groove green;"></textarea>

<!--inset-->
<input style="outline: 5px inset green;" type="text" placeholder="outline: 5px inset green;">
<textarea style="outline: 5px inset green;" placeholder="outline: 5px inset green;"></textarea>

<!--outset-->
<input style="outline: 5px outset green;" type="text" placeholder="outline: 5px outset green;">
<textarea style="outline: 5px outset green;" placeholder="outline: 5px outset green;"></textarea>

<!--none-->
<input style="outline: none;" type="text" placeholder="outline: none;">
<textarea style="outline: none;" placeholder="outline: none;"></textarea>

<!--Không dùng outline-->
<input  type="text" placeholder="Không dùng outline">
<textarea = placeholder="Không dùng outline"></textarea>

<!--initial - Đưa giá trị của thuộc tính outline về giá trị mặc định-->
<input style="outline: 5px initial green;" type="text" placeholder="outline: 5px initial green;">
<textarea style="outline: 5px initial green;" placeholder="outline: 5px initial green;"></textarea>

<!--inherit - Kế thừa thuộc tính outline từ phần tử cha-->
<input style="outline: 5px inherit green;" type="text" placeholder="outline: 5px inherit green;">
<textarea style="outline: 5px inherit green;" placeholder="outline: 5px inherit green;"></textarea>

</body>
</html>

Chạy Thử

Lời kết

Cảm ơn các bạn đã tham khảo bài viết Thuộc tính outline trong CSS.

  • 0 Bình luận
Content Trần Ngọc Thanh
Trần Ngọc Thanh
Content Trần Ngọc Thanh là người viết content có kinh nghiệm nhiều năm tại Web Mới, chuyên viết content bên lĩnh vực website và nhiều lĩnh vực khác
Chia sẻ nội dung đánh giá của bạn về Thuộc tính outline trong CSS
Email, Điện thoại của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *
Đánh giá của bạn
Tên *
Email
Số điện thoại *
Bình luận, Hỏi đáp
Đăng ký tư vấn miễn phí
Tìm hiểu 1 năm không bằng lắng nghe 1 câu tư vấn
Kiến thức PHP
Kiến thức JavaScript
Kiến thức về website
Kiến thức SEO website
0398.259.259