从页面右下方弹出的html css通知程序

时间:2021-07-26 18:57:36

I need a notifier that pops up from bottom right side of the page. I have seen this on many sites including facebook as chat message from Friends. I have search bootstrap, jquery and many other things but could not get what I am looking for.

我需要一个从页面右下方弹出的通知程序。我在许多网站上都看到了这个,包括来自朋友的聊天消息。我有搜索bootstrap,jquery和许多其他的东西,但无法得到我想要的东西。

Any info you have?

你有任何信息?

2 个解决方案

#1


7  

What you require are known as Toast Notifications, or Toaster Popups, or a similar term.

您需要的内容称为Toast Notifications,Toaster Popups或类似术语。

Toastr is one such http://codeseven.github.io/toastr/

Toastr就是其中之一http://codeseven.github.io/toastr/

Here is a demo page for it http://codeseven.github.io/toastr/demo.html

这是http://codeseven.github.io/toastr/demo.html的演示页面

toastr.options = {
  "closeButton": true,
  "debug": false,
  "newestOnTop": false,
  "progressBar": false,
  "positionClass": "toast-bottom-right",
  "preventDuplicates": false,
  "onclick": null,
  "showDuration": "300",
  "hideDuration": "1000",
  "timeOut": "5000",
  "extendedTimeOut": "1000",
  "showEasing": "swing",
  "hideEasing": "linear",
  "showMethod": "fadeIn",
  "hideMethod": "fadeOut"
};

toastr.info("This is a message <img src=\"http://news.bbcimg.co.uk/media/images/71977000/jpg/_71977649_71825880.jpg\" />", "Toaster Popup");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet"/>
<div id="toast"></div>

#2


3  

You could use positioning in order to avoid adding more weight to your project in the form of extra external library's. I've used jquery (yes, a library) although plain vanilla JS would also be sufficient to 'toggling the class'.

您可以使用定位,以避免以额外的外部库的形式为项目增加更多权重。我已经使用了jquery(是的,一个库),虽然普通的vanilla JS也足以“切换类”。

This allows for a much easier customisation of the notification as well.

这样也可以更容易地自定义通知。

I've made a simple, rough example of this:

我做了一个简单粗略的例子:

$('.pop').click(function() {
  $('.popup').toggleClass("open");
});

$('.band').click(function() {
  $('.popup').toggleClass("open");
});
.popup {
  height: 150px;
  width: 250px;
  background: gray;
  bottom: -170px;
  right: 0;
  position: absolute;
  transition: all 0.8s;
  padding-top: 20px;
  border-radius: 10px;
  vertical-align:top;
}
.open {
  bottom: 0;
}
body {
  overflow: hidden;
}
.band {
  position: absolute;
  top: 0;
  width: 100%;
  height: 20px;
  background: rgba(0, 0, 0, 0.2);
  text-align: right;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  transition: all 0.8s;
}
.popup:hover {
  box-shadow: inset 0 0 15px black;
}
.band:hover {
  background: white;
}
html,
body {
  background: rgba(0, 0, 0, 0.3);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="pop">toggle popup</button>
<div class="popup">
  <div class="band">close/dismiss</div>
  <img src="http://placekitten.com/g/200/300" height="60" width="40"/>
  Someone say popup?
 </div>

#1


7  

What you require are known as Toast Notifications, or Toaster Popups, or a similar term.

您需要的内容称为Toast Notifications,Toaster Popups或类似术语。

Toastr is one such http://codeseven.github.io/toastr/

Toastr就是其中之一http://codeseven.github.io/toastr/

Here is a demo page for it http://codeseven.github.io/toastr/demo.html

这是http://codeseven.github.io/toastr/demo.html的演示页面

toastr.options = {
  "closeButton": true,
  "debug": false,
  "newestOnTop": false,
  "progressBar": false,
  "positionClass": "toast-bottom-right",
  "preventDuplicates": false,
  "onclick": null,
  "showDuration": "300",
  "hideDuration": "1000",
  "timeOut": "5000",
  "extendedTimeOut": "1000",
  "showEasing": "swing",
  "hideEasing": "linear",
  "showMethod": "fadeIn",
  "hideMethod": "fadeOut"
};

toastr.info("This is a message <img src=\"http://news.bbcimg.co.uk/media/images/71977000/jpg/_71977649_71825880.jpg\" />", "Toaster Popup");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet"/>
<div id="toast"></div>

#2


3  

You could use positioning in order to avoid adding more weight to your project in the form of extra external library's. I've used jquery (yes, a library) although plain vanilla JS would also be sufficient to 'toggling the class'.

您可以使用定位,以避免以额外的外部库的形式为项目增加更多权重。我已经使用了jquery(是的,一个库),虽然普通的vanilla JS也足以“切换类”。

This allows for a much easier customisation of the notification as well.

这样也可以更容易地自定义通知。

I've made a simple, rough example of this:

我做了一个简单粗略的例子:

$('.pop').click(function() {
  $('.popup').toggleClass("open");
});

$('.band').click(function() {
  $('.popup').toggleClass("open");
});
.popup {
  height: 150px;
  width: 250px;
  background: gray;
  bottom: -170px;
  right: 0;
  position: absolute;
  transition: all 0.8s;
  padding-top: 20px;
  border-radius: 10px;
  vertical-align:top;
}
.open {
  bottom: 0;
}
body {
  overflow: hidden;
}
.band {
  position: absolute;
  top: 0;
  width: 100%;
  height: 20px;
  background: rgba(0, 0, 0, 0.2);
  text-align: right;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  transition: all 0.8s;
}
.popup:hover {
  box-shadow: inset 0 0 15px black;
}
.band:hover {
  background: white;
}
html,
body {
  background: rgba(0, 0, 0, 0.3);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="pop">toggle popup</button>
<div class="popup">
  <div class="band">close/dismiss</div>
  <img src="http://placekitten.com/g/200/300" height="60" width="40"/>
  Someone say popup?
 </div>