Hướng dẫn thông báo bootstrap

Cách tạo thông báo tự đóng bằng Bootstrap

Trong bài học lập trình web này các Bạn sẽ được Cách tạo thông báo tự đóng bằng Bootstrap

Bước 1: Tạo cấu trúc HTML

 
 

Cách tạo thông báo tự đóng bằng Bootstrap


Đăng ký thành viên VIP365

Thỏa sức học thiết kế web và lập trình web với tài khoản VIP365 tại website hocwebgiare.com
Học phí: 500.000đ /1 năm
Áp dụng: Từ 24/02/2017 đến 28/02/2017
Ngày hết hạn đăng ký: Ngày 28/02/2017
Liên hệ: 0199 257 6350 - 0932 152 592

Đăng ký thành viên VIP365

Thỏa sức học thiết kế web và lập trình web với tài khoản VIP365 tại website hocwebgiare.com
Học phí: 500.000đ /1 năm
Áp dụng: Từ 24/02/2017 đến 28/02/2017
Ngày hết hạn đăng ký: Ngày 28/02/2017
Liên hệ: 0199 257 6350 - 0932 152 592

Đăng ký thành viên VIP365

Thỏa sức học thiết kế web và lập trình web với tài khoản VIP365 tại website hocwebgiare.com
Học phí: 500.000đ /1 năm
Áp dụng: Từ 24/02/2017 đến 28/02/2017
Ngày hết hạn đăng ký: Ngày 28/02/2017
Liên hệ: 0199 257 6350 - 0932 152 592

Đăng ký thành viên VIP365

Thỏa sức học thiết kế web và lập trình web với tài khoản VIP365 tại website hocwebgiare.com
Học phí: 500.000đ /1 năm
Áp dụng: Từ 24/02/2017 đến 28/02/2017
Ngày hết hạn đăng ký: Ngày 28/02/2017
Liên hệ: 0199 257 6350 - 0932 152 592

Bước 2: Định dạng CSS

.alert-message{    
margin: 20px 0;    
padding: 20px;    
border-left: 3px solid #eee;
}

.alert-message h4{    
margin-top: 0;    
margin-bottom: 5px;
}

.alert-message p:last-child{    
margin-bottom: 0;
}

.alert-message code{    
background-color: #fff;    
border-radius: 3px;
}

.alert-message-success{    
background-color: #F4FDF0;    
border-color: #3C763D;
}

.alert-message-success h4{    
color: #3C763D;
}

.alert-message-danger{    
background-color: #fdf7f7;    
border-color: #d9534f;
}

.alert-message-danger h4{    
color: #d9534f;
}

.alert-message-warning{    
background-color: #fcf8f2;    
border-color: #f0ad4e;
}

.alert-message-warning h4{    
color: #f0ad4e;
}

.alert-message-info{    
background-color: #f4f8fa;    
border-color: #5bc0de;
}

.alert-message-info h4{    
color: #5bc0de;
}
.alert-message-default{    
background-color: #EEE;    
border-color: #B4B4B4;
}

.alert-message-default h4{    
color: #000;
}

.alert-message-notice{    
background-color: #FCFCDD;    
border-color: #BDBD89;
}

.alert-message-notice h4{    
color: #444;
}

Bước 3: Gọi thư viện Bootstrap và Font awesome

 
 
  

Bước 4: Gọi thư viện JQUERY

 

Bước 5: Tạo chức năng đóng bằng JQUERY

$(document).ready(function () {         
$('.alert-autocloseable-success').hide();	
	$('.alert-autocloseable-warning').hide();	
	$('.alert-autocloseable-danger').hide();	
	$('.alert-autocloseable-info').hide();	
	$('#autoclosable-btn-success').click(function() {	
		$('#autoclosable-btn-success').prop('disabled', true);	
		$('.alert-autocloseable-success').show();	
		$('.alert-autocloseable-success').delay(5000).fadeOut( 'slow', function() {	
			$('#autoclosable-btn-success').prop('disabled', false);	
		});
		});	
	$('#normal-btn-success').click(function() {	
		$('.alert-normal-success').show();		});	
	$('#autoclosable-btn-warning').click(function() {	
		$('#autoclosable-btn-warning').prop('disabled', true);	
		$('.alert-autocloseable-warning').show();	
		$('.alert-autocloseable-warning').delay(3000).fadeOut( 'slow', function() {
$('#autoclosable-btn-warning').prop('disabled', false);	
		});	
	});	
	$('#normal-btn-warning').click(function() {	
		$('.alert-normal-warning').show();		});	
	$('#autoclosable-btn-danger').click(function() {	
		$('#autoclosable-btn-danger').prop('disabled', true);	
		$('.alert-autocloseable-danger').show();			$('.alert-autocloseable-danger').delay(5000).fadeOut( 'slow', function() {	
			$('#autoclosable-btn-danger').prop('disabled', false);			});		});	
		$('#normal-btn-danger').click(function() {	
		$('.alert-normal-danger').show();		});	
	$('#autoclosable-btn-info').click(function() {	
		$('#autoclosable-btn-info').prop('disabled', true);	
		$('.alert-autocloseable-info').show();

			$('.alert-autocloseable-info').delay(6000).fadeOut( 'slow', function() {	
			$('#autoclosable-btn-info').prop('disabled', false);			});		});	
	$('#normal-btn-info').click(function() {			$('.alert-normal-info').show();	
	});	
	$(document).on('click', '.close', function () {			$(this).parent().hide();    	
});
});
Xem  demo Tải Code Chat với hocwebgiare.com

    Tags:
  • Thông báo
  • Thông báo tự đóng
  • Cách tạo thông báo
  • Bootstrap Alerts
  • Alert Messages
  • Học lập trình web

Bạn có thể quan tâm

Cách tạo menu bằng Bootstrap (Phần 5)

Cách tạo menu bằng Bootstrap (Phần 4)

Cách tạo menu bằng Bootstrap (Phần 3)

Cách tạo menu bằng Bootstrap (Phần 2)

Cách tạo menu bằng Bootstrap (Phần 1)

Cách tạo menu Tabs trong Bootstrap (Phần 2)

Cách tạo menu Tabs trong Bootstrap (Phần 1)

Hướng dẫn cách tạo Button Groups trong Bootstrap (Phần 3)

Hướng dẫn cách tạo Button Groups trong Bootstrap (Phần 2)

Hướng dẫn cách tạo Button Groups trong Bootstrap (Phần 1)

Tìm kiếm phổ biến

  • Bootstrap badges
  • Bootstrap
  • Bootstrap Tooltip
  • Bootstrap Lightbox
  • Bootstrap Collapsible Panel
  • Bootstrap Modalbox
  • Bootstrap Fancybox
  • Bootstrap Datepicker
  • Bootstrap Scrollspy
  • Bootstrap touchspin
  • Bootstrap icon
  • Bootstrap narbar
  • Bootstrap tab
  • Bootstrap slideshow
  • Bootstrap gallery
  • Bootstrap banner
  • Bootstrap buttons
  • Bootstrap alerts
  • Bootstrap templates
  • Bootstrap progress bars
  • Bootstrap breadcrumb
  • Bootstrap tables
  • Bootstrap forms
  • Bootstrap modals
  • Bootstrap Grid System
  • Bootstrap slider
  • Bootstrap carousel
  • Bootstrap mega menu
  • Bootstrap vertical menu
  • Bootstrap horizontal menu
  • Bootstrap navigation bar
  • Bootstrap menu
  • Bootstrap accordion