我有一个导航栏水平溢出,我可以用手指在手机上滚动左/右。我还可以左右滑动主要观看区域,以更改选定的导航项目。当我这样做时,如果浏览项目不在视图中,除非您滚动,否则无法看到它。水平溢出导航保留项目在视图
如果在类.active
中选择了导航项,那么我是否可以将导航项放入视图中?
/* The main container */
.container .categories {
overflow: hidden;
overflow-x: scroll;
white-space: nowrap;
position: fixed;
line-height: 20px;
z-index: 200;
background: #000;
top: 50px;
width: 100vw;
}
/* The item within the container */
.container .categories span {
padding: 20px 15px;
display: inline-block;
font-weight: 300;
border-bottom: solid 4px transparent;
transition: border-bottom 0.2s ease-in-out;
}
/* The selected item */
.container .categories span.active {
border-bottom: solid 4px #f47d25;
}
在.container .categories span.active
有没有一种方法,我可以确保该项目在当它是积极的看法?
这里是小提琴:https://jsfiddle.net/x9wpbkrj/5/
如果您制作jsfiddle.net,这将会非常有帮助! –
@SohaibMohammed我添加了一个小提琴。因为您可以看到选定的项目不在视图中(如果视图足够小)。我如何强制选择的项目在视图中? (除非用户手动滑动左/右导航 –