我只是想知道是否有人有办法让这些幻灯片在中间垂直对齐。我在 CSS 和其他建议中尝试了 vertical-position: middle;
但无济于事。
最佳答案
有时我会使用这个片段来垂直对齐东西,因为 CSS 的 vertical-align 往往是喜怒无常的 ;)
(function ($) {
$.fn.vAlign = function(fn) {
return this.each(
function(i){
var ah = $(this).height();
var ph = $(this).parent().height();
var mh = Math.ceil((ph-ah) / 2);
$(this).css('margin-top', mh);
});
};
})(jQuery);
然后你可以这样调用它:$(".your-element").vAlign();
关于javascript - 使用 css 或在 flexslider.js 中将幻灯片对齐到中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13937394/