I am building a site using Flask and Bootstrap and I have long lists of objects that I want to display on the page. I have a 6 column layout and I want the list spill over one column to the next. I know I can do this on the python side but I am wondering if there is a way that bootstrap or CSS can handle it?
UPDATE: better explanation --> I want a long list of names to be divided up in to six equal(ish) columns. I can divide the list on the backend but was hoping there is a way to do this on the front end.
UPDATE UPDATE: Duh! here is what I was looking for ...
'''Jinja
<div class="container">
<div class="row">
<div class="col-2">
<!--I want this part to flow over all 6 columns-->
{% for name in names %}
{{name.firstname}} {{name.lastname}} <br>
{% endfor %}
</div>
</div>
</div>
''''
Because the columns automatically wrap after 12 columns I don't need to code each column. That's what I was missing. Thank you everyone!
To make 6 even columns, you can create a single container, a single row then an element for each item in your list with the class "col-2" (these could be divs, links, list items, etc). Bootstrap will automatically make each element 1/6 of the screen wide. And even though you only have one "row" div, Bootstrap will make all of your elements flow into as many rows as needed.
The code below will give you 2 rows of 6 columns.
<div class="container-fluid">
<div class="row">
<div class="col-2">Element 1</div>
<div class="col-2">Element 2</div>
<div class="col-2">Element 3</div>
<div class="col-2">Element 4</div>
<div class="col-2">Element 5</div>
<div class="col-2">Element 6</div>
<div class="col-2">Element 7</div>
<div class="col-2">Element 8</div>
<div class="col-2">Element 9</div>
<div class="col-2">Element 10</div>
<div class="col-2">Element 11</div>
<div class="col-2">Element 12</div>
</div>
</div>
I think you can achieve what you want with simple bootstrap grid system.
<div class="row">
<div class="col-2"></div>
<div class="col-2"></div>
...
...
<div class="col-2"></div>
</div>
here is what I was looking for
'''Jinja
<div class="container">
<div class="row">
<div class="col-2">
<!--I want this part to flow over all 6 columns-->
{% for name in names %}
{{name.firstname}} {{name.lastname}} <br>
{% endfor %}
</div>
</div>
</div>
''''
I don't need to code each column separately! The for loop puts each item in a 2 column wide column that automatically wraps after 12 total columns. That's what I was missing. Thank you everyone!
Related
I'm creating a real estate with boostrap ccs and i'm trying organized my ads. However i can't find the way to make them all to the same size. i want for each line 3 ads. In this search only found 5 ads.
the next image is what i have using:
div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-5"
My situation
And what i'm looking for is:
The future
thanks for helping me
<div class="row">
<div class="col-4">
<!-- Add advert item here -->
</div>
<div class="col-4">
<!-- Add advert item here -->
</div>
<div class="col-4">
<!-- Add advert item here -->
</div>
</div>
<div class="row">
<div class="col-4">
<!-- Add advert item here -->
</div>
<div class="col-4">
<!-- Add advert item here -->
</div>
</div>
Also you will need to adjust for media queries for smaller screens.
Using OOTB SXA, I am trying to render selected items from Multilist with Search.
The data renders, but with everything nested in a single <li> broken into <div>'s
Among other things, I've tried using and Item Query (re: https://ggullentops.blogspot.com/2017/04/sitecore-sxa-pagelist-item-query.html), but didn't have any success.
Q: What is the correct way to render my items as individual <li>'s?
Current Results displayed:
<main>
<div id="content" class="container">
<div class="component page-list col-12">
<div class="component-content">
<ul class="items">
<li class="item">
<div class="field-first-name">Stephen</div>
<div class="field-last-name">King</div>
<div class="field-first-name">Gregory</div>
<div class="field-last-name">Mertens</div>
<div class="field-first-name">Penny</div>
<div class="field-last-name">Mertens</div>
</li>
</ul>
</div>
</div>
</div>
</main>
Multi Select List Data Source:
List Item:
Control Properties:
Rendering Variant
With Zurb foundation version 3, if I include the foundation.css file
I'm able to make grids, etc.
With version 4, if I do everything the same way, it does not work.
What am I missing?
If I do everything the same way
There are new classes to use for grids in V4. You cannot just say four columns but instead specify if the columns are for a large or small view/device. So you need to have small-X or large-X where X is the number of columns a div needs to consume. Here's an example:
<div class="row">
<div class="ten columns centered">
<h1>This grid won't work on V4</h1>
<div class="row">
<div class="four columns">
<div class="panel">
<p>Left panel</p>
</div>
</div>
<div class="four columns">
<div class="panel">
<p>Center panel</p>
</div>
</div>
<div class="four columns">
<div class="panel">
<p>Right panel</p>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="ten columns centered">
<h1>But this will...</h1>
<div class="row">
<div class="small-2 large-4 columns">
<div class="panel">
<p>Left panel</p>
</div>
</div>
<div class="small-4 large-4 columns">
<div class="panel">
<p>Center panel</p>
</div>
</div>
<div class="small-6 large-4 columns">
<div class="panel">
<p>Right panel</p>
</div>
</div>
</div>
</div>
</div>
Notice the combination of small and large on a single div. What it tells you is that the Left panel will only be two columns on small devices (mobile phones) and four columns on large devices such as on a desktop. Similarly, the Right panel will be six columns on small devices and four columns on large devices. You can see the difference by playing with the size of your browser.
To get more information on how the V4 Grid works, go to this page.
I am testing foundation 3 framework and was wondering how i can set a row with five articles.
Does anyone have an idea to fix that?
One solution is to use columns of two and mark the last column as the end.
If your row doesn't have a count that adds up to 12 columns, you can
tag the last column with class="end" in order to override that
behaviour. [source]
<div class="row">
<div class="two columns">
article 1
</div>
<div class="two columns">
article 2
</div>
<div class="two columns">
article 3
</div>
<div class="two columns">
article 4
</div>
<div class="two columns end">
article 5
</div>
</div>
Alternatively if you need to use all the space you can use a block grid:
Block grids are made from a ul.block-grid with #-up styles chained to
it. You control how many you have in your Scss setting file or the
customizer. These are ideal for blocked-in content generated by an
application, as they do not require rows or even numbers of elements
to display correctly.
<ul class="block-grid five-up">
<li>article 1</li>
<li>article 2</li>
<li>article 3</li>
<li>article 4</li>
<li>article 5</li>
</ul>
This should work in Foundation 5 (maybe 3 as well). The trick is to offset the first column and end the last.
<nav>
<div class="row">
<div class="column small-2 small-offset-1">
<a>Link</a>
</div>
<div class="column small-2">
<a>Link</a>
</div>
<div class="column small-2">
<a>Link</a>
</div>
<div class="column small-2">
<a>Link</a>
</div>
<div class="column small-2 end">
<a>Link</a>
</div>
</div>
</nav>
Hope it helps someone, or a future me.
How do output the following? I want to output the "grid" class after exactly 4 "block" classes. The inner divs are objects returned from a view.
<div class="grid">
<div class="block">...</div>
<div class="block">...</div>
<div class="block">...</div>
<div class="block">...</div>
</div>
<div class="grid">
<div class="block">...</div>
<div class="block">...</div>
<div class="block">...</div>
<div class="block">...</div>
</div>
...
I've tried using forloop.counter0|divisibleby:4 with no success.
I think you're on the right track with the counter method. However, it looks like you just have a couple syntax errors that are tripping you up. You probably want forloop.counter|divisibleby:"4", so something like
<div class="grid">
{% for item in items %}
<div class="block">...</div>
{% if forloop.counter|divisibleby:"4" %}
</div>
<div class="grid">
{% endif %}
{% endfor %}
</div>
should do the trick.
Try forloop.counter|divisibleby:4. The addition of the zero means the loop is zero indexed. By the time you get to the 4th loop the counter will only read 3 which isn't evenly dividable by 4.