<div class="stuck">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex
ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit
augue duis dolore te feugait nulla facilisi.</p>
</div>
<div class="not-stuck">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex
ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue
duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem.
Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit
litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt
ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue
nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam
processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc
nobis videntur parum clari, fiant sollemnes in futurum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci
tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem
insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam
littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum. Lorem ipsum dolor sit amet, consectetuer
adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum
iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores
legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula
quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</div>
//start MOBILE NAV
$('#mobnav-btn').click(
function() {
$("html").toggleClass("mobile-menu-open");
$(".xnav-wrapper").delay(500).queue(function(reset_scroll) {
$(this).scrollTop(0);
reset_scroll();
});
});
//end MOBILE NAV
<!-- start MOBILE BTN -->
<div id="mobnav-btn">
<div class="mobnav-icon">
Menu
</div>
</div>
<!-- end MOBILE BTN -->
<!-- start REGULAR CMS NAV -->
<div class="xnav">
<div class="xnav-wrapper">
<ul class="sf-menu">
<li><a href="#">Home</a></li>
<li><a href="#">Cupcakes</a>
<ul>
<li><a href="#">1.1 Cupcakes</a></li>
<li><a href="#">1.2 Cupcakes</a></li>
<li><a href="#">1.3 Cupcakes</a>
<ul>
<li><a href="#">2.1 Cupcakes</a></li>
<li><a href="#">2.2 Cupcakes</a></li>
<li><a href="#">2.3 Cupcakes</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Doughnuts</a></li>
<li><a href="#">Icecream</a></li>
<li><a href="#">Banana Split</a> </li>
<li><a href="#">Brownies</a></li>
<li><a href="#">Lollipop</a></li>
<li><a href="#">Pixie Stix</a></li>
<li><a href="#">Bubble Gum</a></li>
<li><a href="#">Chocolate Chips</a></li>
<li><a href="#">Cherries</a></li>
</ul>
</div>
</div>
<!-- end REGULAR CMS NAV -->
<h1>Mobile Nav </h1>
<b><a href="mailto:RyanBrackett@gmail.com">RyanBrackett@gmail.com</a></b>
<br/>
<br/>The concept is very simple: Off-Canvas navigation based on the active state ( html.mobile-menu-open ). Mobile nav items options scroll if out of viewport.
<br/>
<br/>The CSS portion will be a little different because I had to create some styles that are natively in the framework. Also, the CSS portion will drop into your phone.css and tablet.css files. Cupcake ipsum dolor sit amet. Wafer tootsie roll I love oat
cake. Unerdwear.com icing bear claw liquorice marshmallow gummies cupcake tiramisu. Applicake cupcake powder jelly beans chupa chups muffin. Lollipop bear claw sweet roll macaroon. Jelly-o gummi bears apple pie. I love cheesecake carrot cake pudding toffee
marzipan chupa chups jelly beans dragée. Pie chocolate cake bear claw toffee gingerbread. Chupa chups bonbon lollipop topping I love. Cake dessert cheesecake candy canes sugar plum. Marzipan cookie apple pie muffin lemon drops. Chocolate cake oat cake
brownie cookie apple pie. I love I love sugar plum I love I love chocolate marshmallow lollipop.
<br/>
<br/>Apple pie ice cream dragée. Fruitcake cotton candy jujubes tootsie roll biscuit croissant caramels. Marzipan jelly-o candy I love lollipop bonbon. Applicake chocolate bar tootsie roll bonbon tiramisu jelly jelly beans. Marzipan I love sweet caramels
I love cupcake croissant marshmallow. Gingerbread danish marzipan jelly. Chocolate oat cake danish sugar plum bonbon. Pie gummi bears chocolate bar I love. I love halvah cotton candy sweet roll lollipop apple pie bear claw croissant. Sweet roll bear claw
donut topping. Cupcake I love jelly-o bear claw tootsie roll danish powder liquorice. Tart pastry tootsie roll I love.
<br/>
<br/>Cheesecake bear claw unerdwear.com unerdwear.com. Lemon drops chocolate oat cake donut unerdwear.com cheesecake dragée. Chocolate cake candy canes marzipan biscuit I love. Pudding biscuit powder. Pie gingerbread oat cake apple pie jujubes bonbon
powder. Danish I love I love gingerbread toffee. Icing I love chocolate. Halvah I love I love soufflé gingerbread jelly-o. Lollipop biscuit wafer marzipan I love cheesecake sesame snaps. Oat cake candy canes marzipan croissant. I love caramels cheesecake
chocolate toffee. Fruitcake powder gummies applicake cake lollipop topping icing.
<br/>
<br/>Wafer icing I love sweet jelly. I love muffin I love. Cotton candy I love I love I love candy biscuit. I love marzipan I love pie marshmallow gingerbread sesame snaps. Croissant pudding halvah sugar plum applicake candy I love sugar plum. Gingerbread
apple pie apple pie candy chocolate cake carrot cake jelly-o unerdwear.com. Chocolate sweet roll icing chupa chups brownie oat cake bonbon I love pie. Gummi bears cupcake pudding chocolate bar. Jujubes jelly-o sesame snaps toffee chocolate toffee. I love
toffee gingerbread marshmallow pie chocolate cake jelly beans. Biscuit jujubes jelly pudding gummies apple pie. Chupa chups I love chocolate cake unerdwear.com carrot cake I love sweet roll marshmallow.
<br/>
<br/>Cotton candy macaroon pudding croissant ice cream sesame snaps tiramisu. Unerdwear.com sweet roll candy I love. Tootsie roll soufflé lollipop chocolate cake soufflé. Jelly tootsie roll I love I love I love donut oat cake. Gummies croissant pastry
candy brownie ice cream. Wafer muffin icing. I love icing apple pie bonbon jelly I love jelly beans chupa chups. Candy bonbon carrot cake. Croissant I love candy canes pudding donut toffee. Cotton candy ice cream chupa chups candy canes muffin croissant
sesame snaps marshmallow. I love soufflé donut donut. Jelly beans bear claw sugar plum biscuit toffee gummi bears. Tiramisu lollipop applicake jujubes chocolate bar donut pudding chocolate bar bear claw.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
9条答案
按热度按时间gijlo24d1#
你可能做不到。这里有一个很接近的东西。如果下面有空间,你就不会让内容围绕它流动。
也可以设置高度百分比:
一个二个一个一个
vq8itlhq2#
下面是我如何做到这一点。你只需要使用一些聪明的前端开发!!
b5lpy0ml3#
在你的位置试试这个:固定元素。
jrcvhitl4#
你可能需要一个内部的div。用css是:
soat7uwm5#
这是绝对可行的一些flexbox魔术。看看这个pen。
你需要这样的CSS:
这在IE10+中有效
9rnv2umw6#
下面是纯粹的HTML和CSS解决方案。
1.我们为导航栏创建一个容器框,其位置为:固定;高度:100%;
1.然后我们创建一个具有高度的内框:100%;溢出y:滚动;
1.接下来,我们将内容放入该框中。
下面是代码:
Link to jsFiddle:
8iwquhpp7#
出于您的目的,您可以使用
并且它仍然是可调整大小、可滚动和响应的。
oaxa6hgo8#
我把它作为一个变通方法而不是一个解决方案来介绍。这可能不是一直都有效。我是这样做的,因为我正在一个非常奇怪的环境中做一个非常基本的HTML页面,供内部使用。我知道有一些像MaterializeCSS这样的库可以做非常好的导航栏。(我打算使用它们,但它不适合我的环境。)
cwtwac6a9#
将此添加到固定高度的代码中,并添加一个滚动条。