在这方面需要帮助,我找不到其他解决方案
基本上我需要的是在屏幕宽度上水平调整图标的列表
因此,如果我在水平方向上有七个图标,那么当我在平板电脑中时,不合适的图标将进入某个具有滑动和下移效果的div
因此,如果ipad仅显示6个图标,则第七个图标将在div上
我有一张图片供说明
我真的很需要帮助,谢谢
奥利弗,
这是一个广泛的问题,因为有几种方法可以解决此问题。我确定那里有一两个图书馆可以帮助您完成此任务。如果您打算自己做,则将要开始以下任务。
为了帮助您入门,我整理了一个使用jQuery完成此任务的简单示例。有关完整的工作示例,请参见本文底部的JSFiddle。
$(document).ready(function() {
// Get reference to our static elements
// one time at load for performance
var $nav = $('nav');
var $primaryList = $nav.find('.primary-list ul');
var $overflowList = $nav.find('.overflow-list ul');
var $overflowButton = $('#show-overflow');
// Bind our overflow toggle for the overflow list
$overflowButton.click(function() {
$nav.toggleClass('show-overflow');
});
// Bind our resize event so we know when
// viewport size changes
$(window).resize(function() {
// Find our last item in primary list
var $pl = $primaryList.find('li:last');
// Figure out the right side of our last element
var x = $pl.position().left + $pl.outerWidth();
var listWidth = $primaryList.innerWidth();
// Check to see if this is outside of our menu
if (x > listWidth) {
// Since this is outside we move it to overflow
$pl.prependTo($overflowList);
// Show our overflow button
$overflowButton.show();
} else {
// Since this didn't overflow lets see if we have enough
// room to move an overflow element back to the primary list
var $ol = $overflowList.find('li:first');
// Check to see if we found an overflow element
if ($ol.length > 0) {
// Check to see if this one will fit
if (x + $ol.outerWidth() <= listWidth) {
// Move it back to the primary list
$ol.appendTo($primaryList);
}
} else {
// Hide our overflow button
$overflowButton.hide();
}
}
}).resize();
});
https://jsfiddle.net/gayv02gy/2/
干杯!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句