Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
539 views
in Technique[技术] by (71.8m points)

javascript - 使用Bootstrap 4进行??全宽度扩展的可扩展网格(Expandable grid with full width expansion using Bootstrap 4)

I'm trying to make a grid for a gallery with an expanding preview, showing the details.(我正在尝试为具有扩展预览的画廊制作网格,以显示详细信息。)

I am using the code from this nice article: https://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/ Everything works fine but I want to use Bootstrap 4 to make it responsive.(我正在使用这篇文章中的代码: https : //tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/一切正常,但我想使用Bootstrap 4使其响应。) The problem I'm facing is that the expansion is now inside the column, making it the same width instead of the full page width.(我面临的问题是扩展现在在列内,使其具有相同的宽度而不是整个页面宽度。) Is there a way to make it full width or place the expansion outside the column?(有没有办法使它全宽或将扩展放置在列的外面?) <section class="films"> <div class="container-fluid"> <div id="og-grid" class="og-grid row"> <div class="movie col-md-4"> <a class="portfolio-box" href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/portfolio/fullsize/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot."> <img class="img-fluid" src="images/portfolio/thumbnails/1.jpg" alt="img01"/> </a> </div> <div class="movie col-md-4"> <a class="portfolio-box" href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/portfolio/fullsize/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot."> <img class="img-fluid" src="images/portfolio/thumbnails/1.jpg" alt="img01"/> </a> </div> <div class="movie col-md-4"> <a class="portfolio-box" href="http://cargocollective.com/jaimemartinez/" data-largesrc="images/portfolio/fullsize/1.jpg" data-title="Azuki bean" data-description="Swiss chard pumpkin bunya nuts maize plantain aubergine napa cabbage soko coriander sweet pepper water spinach winter purslane shallot tigernut lentil beetroot."> <img class="img-fluid" src="images/portfolio/thumbnails/1.jpg" alt="img01"/> </a> </div> </div> </div> </section> The original CSS: https://github.com/codrops/ThumbnailGridExpandingPreview/blob/master/css/component.css(原始CSS: https : //github.com/codrops/ThumbnailGridExpandingPreview/blob/master/css/component.css) And JS: https://github.com/codrops/ThumbnailGridExpandingPreview/blob/master/js/grid.js(和JS: https//github.com/codrops/ThumbnailGridExpandingPreview/blob/master/js/grid.js)   ask by Fay translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Codrops example is very complex, and it would be difficult to make responsive.(Codrops示例非常复杂,很难做出响应。)

Since you want to use Bootstrap's responsiveness, you could instead use the Collapse component along with some JS logic to order the details column as desired.(由于要使用Bootstrap的响应能力,因此可以改用Collapse组件以及一些JS逻辑来按需对详细信息列进行排序。) The jQuery/JS in this case is simpler, and aligns with Bootstraps's grid breakpoints.(在这种情况下,jQuery / JS更简单,并且与Bootstraps的网格断点保持一致。) No extra CSS (beyond Bootstrap) is needed...(不需要额外的CSS(超越Bootstrap)...) // initialize all cols with their natural order $('.col-md-2').each(function(i,ele){ let idx = $(ele).index('.col-md-2') $(this).css('order',idx) }) // set the flexbox order of the details col in each row var calcOrder = function(perRow){ $('.collapse').each(function(i,ele){ var idx = $(ele).index('.collapse') var modIdx = idx % perRow var posi = parseInt((perRow-modIdx) + idx) $(this).css('order',posi) }) } // determine number per row based on window width var breakpoints = function(width) { if (width >= 776) { //md calcOrder(6) } else if (width >= 567) { //sm calcOrder(3) } else { //xs calcOrder(2) } } // reset order on window resize $(window).on('resize', function(){ var win = $(this) breakpoints(win.width()) }) Demo: https://codeply.com/p/Fs1zOQCk1q(演示: https//codeply.com/p/Fs1zOQCk1q) Also see: Bootstrap Expanding Grid(另请参阅: Bootstrap扩展网格)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...