Tất cả bài viết | Bootstrap
Hướng dẫn thiết giao diện trang giỏ hàng bằng Bootstrap
Trong bài thực hành học thiết kế web này các Bạn sẽ được Hướng dẫn thiết giao diện trang giỏ hàng bằng Bootstrap
Bước 1: Tạo cấu trúc HTML cho giỏ hàng
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | < h2 class = "text-center" >Hướng dẫn thiết giao diện trang giỏ hàng bằng Bootstrap</ h2 > < div class = "container" > < table id = "cart" class = "table table-hover table-condensed" > < thead > < tr > < th style = "width:50%" >Tên sản phẩm</ th > < th style = "width:10%" >Giá</ th > < th style = "width:8%" >Số lượng</ th > < th style = "width:22%" class = "text-center" >Thành tiền</ th > < th style = "width:10%" > </ th > </ tr > </ thead > < tbody >< tr > < td data-th = "Product" > < div class = "row" > < div class = "col-sm-2 hidden-xs" >< img src = "http://hocwebgiare.com/thiet_ke_web_chuan_demo/shopping_cart/images/090.jpg" alt = "Sản phẩm 1" class = "img-responsive" width = "100" > </ div > < div class = "col-sm-10" > < h4 class = "nomargin" >Sản phẩm 1</ h4 > < p >Mô tả của sản phẩm 1</ p > </ div > </ div > </ td > < td data-th = "Price" >200.000 đ</ td > < td data-th = "Quantity" >< input class = "form-control text-center" value = "1" type = "number" > </ td > < td data-th = "Subtotal" class = "text-center" >200.000 đ</ td > < td class = "actions" data-th = "" > < button class = "btn btn-info btn-sm" >< i class = "fa fa-edit" ></ i > </ button > < button class = "btn btn-danger btn-sm" >< i class = "fa fa-trash-o" ></ i > </ button > </ td > </ tr > < tr > < td data-th = "Product" > < div class = "row" > < div class = "col-sm-2 hidden-xs" >< img src = "http://hocwebgiare.com/thiet_ke_web_chuan_demo/shopping_cart/images/174.jpg" alt = "Sản phẩm 1" class = "img-responsive" width = "100" > </ div > < div class = "col-sm-10" > < h4 class = "nomargin" >Sản phẩm 2</ h4 > < p >Mô tả của sản phẩm 2</ p > </ div > </ div > </ td > < td data-th = "Price" >300.000 đ</ td > < td data-th = "Quantity" >< input class = "form-control text-center" value = "1" type = "number" > </ td > < td data-th = "Subtotal" class = "text-center" >300.000 đ</ td > < td class = "actions" data-th = "" > < button class = "btn btn-info btn-sm" >< i class = "fa fa-edit" ></ i > </ button > < button class = "btn btn-danger btn-sm" >< i class = "fa fa-trash-o" ></ i > </ button > </ td > </ tr > </ tbody >< tfoot > < tr class = "visible-xs" > < td class = "text-center" >< strong >Tổng 200.000 đ</ strong > </ td > </ tr > < tr > < td >< a href = "http://hocwebgiare.com/" class = "btn btn-warning" >< i class = "fa fa-angle-left" ></ i > Tiếp tục mua hàng</ a > </ td > < td colspan = "2" class = "hidden-xs" > </ td > < td class = "hidden-xs text-center" >< strong >Tổng tiền 500.000 đ</ strong > </ td > < td >< a href = "http://hocwebgiare.com/" class = "btn btn-success btn-block" >Thanh toán < i class = "fa fa-angle-right" ></ i ></ a > </ td > </ tr > </ tfoot > </ table > </ div > |
Bước 2: Định dạng CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | < style type = "text/css" >.table&amp;gt;tbody&amp;gt;tr&amp;gt;td, .table&amp;gt;tfoot&amp;gt;tr&amp;gt;td { vertical-align: middle; } @media screen and (max-width: 600px) { table#cart tbody td .form-control { width:20%; display: inline !important; } .actions .btn { width:36%; margin:1.5em 0; } .actions .btn-info { float:left; } .actions .btn-danger { float:right; } table#cart thead { display: none; } table#cart tbody td { display: block; padding: .6rem; min-width:320px; } table#cart tbody tr td:first-child { background: #333; color: #fff; } table#cart tbody td:before { content: attr(data-th); font-weight: bold; display: inline-block; width: 8rem; } table#cart tfoot td { display:block; } table#cart tfoot td .btn { display:block; } }</ style > |
Bước 3: Gọi thư viện Bootstrap
1 | < link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" > <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"> </script> |
Bước 4: Gọi thư viện JQUERY
1 | <script src="js/jquery-1.11.1.min.js"> </script> |
Bootstrap Xem (45722) Học thiết kế web giá rẻ