Thư viện hình ảnh trong CSS
CSS có thể được sử dụng để tạo những bộ sưu tập giúp bạn quản lý hình ảnh trong website của mình.

Chúng được tạo như sau:
Ví dụ 1:
<!DOCTYPE html><html><head><style>div.gallery {margin: 5px;border: 1px solid #ccc;float: left;width: 180px;}div.gallery:hover {border: 1px solid #777;}div.gallery img {width: 100%;height: auto;}div.desc {padding: 15px;text-align: center;}</style></head><body><div class="gallery"><a target="_blank" href="flower-1.jpg"><img src="flower-1.jpg" alt="Beautiful Flower 1" width="400" height="267"></a><div class="desc">Mô tả về ảnh</div></div><div class="gallery"><a target="_blank" href="flower-2.jpg"><img src="flower-2.jpg" alt="Beautiful Flower 2" width="400" height="267"></a><div class="desc">Mô tả về ảnh</div></div><div class="gallery"><a target="_blank" href="flower-3.jpg"><img src="flower-3.jpg" alt="Beautiful Flower 3" width="400" height="267"></a><div class="desc">Mô tả về ảnh</div></div><div class="gallery"><a target="_blank" href="flower-4.jpg"><img src="flower-4.jpg" alt="Beautiful Flower 4" width="400" height="267"></a><div class="desc">Mô tả về ảnh</div></div></body></html>
Ví dụ 2:
Ví dụ này sắp xếp lại hình ảnh trên các kích thước màn hình khác nhau: đối với màn hình rộng hơn 700px, nó sẽ hiển thị bốn hình ảnh cạnh nhau, đối với màn hình nhỏ hơn 700px, nó sẽ hiển thị hai hình ảnh cạnh nhau. Đối với màn hình nhỏ hơn 500px, hình ảnh sẽ xếp chồng theo chiều dọc (100%).
<!DOCTYPE html><html><head><style>div.gallery {border: 1px solid #ccc;}div.gallery:hover {border: 1px solid #777;}div.gallery img {width: 100%;height: auto;}div.desc {padding: 15px;text-align: center;}* {box-sizing: border-box;}.responsive {padding: 0 6px;float: left;width: 24.99999%;}@media only screen and (max-width: 700px) {.responsive {width: 49.99999%;margin: 6px 0;}}@media only screen and (max-width: 500px) {.responsive {width: 100%;}}.clearfix:after {content: "";display: table;clear: both;}</style></head><body><div class="responsive"><div class="gallery"><a target="_blank" href="flower-1.jpg"><img src="flower-1.jpg" alt="Beautiful Flower 1" width="600" height="400"></a><div class="desc">Mô tả về ảnh</div></div></div><div class="responsive"><div class="gallery"><a target="_blank" href="flower-2.jpg"><img src="flower-2.jpg" alt="Beautiful Flower 2" width="600" height="400"></a><div class="desc">Mô tả về ảnh</div></div></div><div class="responsive"><div class="gallery"><a target="_blank" href="flower-3.jpg"><img src="flower-3.jpg" alt="Beautiful Flower 3" width="600" height="400"></a><div class="desc">Mô tả về ảnh</div></div></div><div class="responsive"><div class="gallery"><a target="_blank" href="flower-4.jpg"><img src="flower-4.jpg" alt="Beautiful Flower 4" width="600" height="400"></a><div class="desc">Mô tả về ảnh</div></div></div><div class="clearfix"></div></body></html>
4.187
Bạn nên đọc
Xác thực tài khoản!
Theo Nghị định 147/2024/ND-CP, bạn cần xác thực tài khoản trước khi sử dụng tính năng này. Chúng tôi sẽ gửi mã xác thực qua SMS hoặc Zalo tới số điện thoại mà bạn nhập dưới đây:
Số điện thoại chưa đúng định dạng!
0 Bình luận
Sắp xếp theo
Xóa Đăng nhập để Gửi
Cũ vẫn chất
-

Search engine (công cụ tìm kiếm) là gì?
2 ngày -

Cách chỉnh kích thước dòng, cột, ô bằng nhau trên Excel
2 ngày -

Cách đặt trình duyệt mặc định khi mở link bất kỳ trên máy tính
2 ngày -

Danh sách tất cả làng trong Coin Master và giá
2 ngày -

Cách truy cập các trang web bị chặn
2 ngày -

Cách dọn dẹp và khôi phục không gian trên ổ C Windows
2 ngày -

Cách căn giữa bảng trong Google Docs
2 ngày -

Cách hiện khung căn lề trong Word
2 ngày -

Số chính phương là gì? Cách nhận biết và ví dụ chi tiết
2 ngày 1 -

Vòng lặp for trong Python
2 ngày
Làm chủ AI
Học IT
AI
Microsoft Word 2013
Microsoft Word 2007
Microsoft Excel 2019
Microsoft Excel 2016
Microsoft PowerPoint 2019
Google Sheets
Lập trình Scratch
Bootstrap
Ô tô, Xe máy