【发布时间】:2018-02-14 01:33:21
【问题描述】:
我正在尝试在表格单元格(两个单元格行的左侧)中定位和包含轮播。轮播不断向右复制,但在整个表格结构不正确的情况下也能正常工作。我这样做的全部原因是垂直对齐轮播和按钮/图像内容,以便在调整浏览器大小时它们保持原位。
这里是完整的代码:
var someFunction = function() {};
(function() {
$('.owl-carousel').owlCarousel({
center: true,
items: 1,
loop: true,
margin: 10,
nav: true,
autoplay: true,
autoplayTimeout: 3000,
animateOut: 'fadeOut',
dots: true,
navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
})
})();
someFunction();
.owl-carousel {
position: relative;
}
.owl-prev,
.owl-next {
position: absolute;
top: 44%;
height: 10vh;
width: 10vh;
}
.owl-prev {
left: 0.5vh;
}
.owl-next {
right: 0.5vh;
}
<link rel="stylesheet" href="https://cdn.shopify.com/s/files/1/2793/0346/files/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdn.shopify.com/s/files/1/2793/0346/files/owl.theme.default.min_home_up_6.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdn.shopify.com/s/files/1/2793/0346/files/owl.carousel.min.js"></script>
<table style="width: 100%;"><tr><td width="75%" style="text-align: center; vertical-align: middle;"><div class="owl-carousel owl-theme"><div class="item" style="width:100%;text-align:center;"><img src="img1.jpg"></div><div class="item" style="width:100%;text-align:center;"><img src="img2.jpg"></div></div></td><td width="25%" style="text-align: center; vertical-align: middle;">Unknown stuff to be centered. </td></tr></table>
任何想法
【问题讨论】:
-
你能给我们找个jsfiddle吗
-
我并不是说你不能用
<table>做到这一点,但现代网页设计通常不赞成它。响应式设计和良好的垂直对齐有更好的选择。 -
@AshishBalchandani jsfiddle?
-
@FatTwin: Flexbox
标签: javascript jquery html css