我有一個導航欄水平溢出,我可以用手指在手機上滾動左/右。我還可以左右滑動主要觀看區域,以更改選定的導航項目。當我這樣做時,如果瀏覽項目不在視圖中,除非您滾動,否則無法看到它。水平溢出導航保留項目在視圖
如果在類.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我添加了一個小提琴。因爲您可以看到選定的項目不在視圖中(如果視圖足夠小)。我如何強制選擇的項目在視圖中? (除非用戶手動滑動左/右導航 –