如何让它响应popover定制的弹出模板?

时间:2015-04-19 04:15:55

标签: javascript jquery css twitter-bootstrap

如何使其响应,因为当它使浏览器变小时,弹出窗口移动而不是位于正确的位置或者简单地按住按钮它没有响应。

请帮助我开始新的开始......

HTML

<button class="btn  btn-default btn-light text-center my-popover"
data-html='true'
data-trigger="focus"
data-container="body" 
data-template='
      <div class="popover" role="tooltip">
          <div class="arrow"></div>
          <div class="popover-top"></div>
          <div class="popover-content"></div>
      </div>' 
data-toggle="popover" 
data-placement="bottom" 
data-content='<h4 id="pop-title">Description</h4>
                 <div class="row pop-content">
                    <ul id="pop-ul" class="list-unstyled col-md-12"> 
                       <li id="pop-li">Reponsive Layout</li>
                       <li id="pop-li">Less Effort</li>
                       <li id="pop-li">Smooth User Experience</li>
                       <li id="pop-li">Statics</li>
                       <li id="pop-li">User Friendly website</li>
                     </ul>
                   </div>
                '>Learn More</button>

JS

(function() {

var orig = $.fn.popover,
    proto = $.extend({}, $.fn.popover.Constructor.prototype);

$.fn.popover = function(options) {
    return this.each(function() {
        orig.call($(this), options);
        if (typeof options.hide == 'function') {
            $(this).data('bs.popover').hide = function() {
                console.log(proto);
                options.hide.call(this.$tip, this);
                proto.hide.call(this);
            };
        }
    });
}

})();

$('.my-popover').popover({
placement: 'bottom',
hide: function() {
    $(this).animate({marginTop: -10}, function() {
        $(this).css({marginTop: 10});
    });
}
});

CSS

.popover {
position:  absolute !important;
top: 0;
left: 0;
z-index: 1060;
display: none;
width: 250px !important;
padding: 0px;
text-align: left;
white-space: normal;
background-color: #fff !important;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #42dca3;
border: 1px solid #42dca3;
border-radius: 0px !important;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
 }

.popover.bottom {
margin-top: 10px;
 }

.popover-title {
 padding: 8px 14px;
 margin: 0;
 font-size: 14px;
 font-weight: normal;
 line-height: 18px;
 background-color: #f7f7f7;
 border-bottom: 1px solid #ebebeb;
 border-radius: 5px 5px 0 0;
 }

.popover-top {
  height: 10px;
  background-color: #42dca3 !important;
}

.popover-content {
  padding: 9px 20px;
}

.popover > .arrow,
.popover > .arrow:after {
  position: absolute;
  display: block;
  width: 0;
  height: 0;
  border-color: transparent;
  border-style: solid;
}

.popover > .arrow {
  border-width: 11px;
}

.popover > .arrow:after {
  content: "";
  border-width: 10px;
}

.popover.bottom > .arrow {
  top: -11px;
  left: 50%;
  margin-left: -11px;
  border-top-width: 0;
  border-bottom-color: ##42dca3;
  border-bottom-color: ##42dca3;
}

.popover.bottom > .arrow:after {
  top: 1px;
  margin-left: -10px;
  content: " ";
  border-top-width: 0;
  border-bottom-color: #42dca3;
 }

0 个答案:

没有答案