Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homepage Article Grid
#1
Hi

I have been tasked to code a homepage in a three-column grid format.

Articles that appear in the homepage grid can be given a layout value which determines how many columns they take up. Articles can be one-column, two-column, or three-column.

Each of the columns is 300 pixels wide, giving a total grid width of 900 pixels.

https://i.ibb.co/FYbRWJ0/Screenshot-2020...-41-50.png

There is a problem with adopting this grid format: depending on the layout values assigned to each article, the grid may end up having gaps. For example, the following article configuration creates the following layout:

[
{ "title": "Star Ocean review", "columns": 2 },
{ "title": "Lego Star Wars review", "columns": 2 },
{ "title": "Prison Architect review", "columns": 1 },
{ "title": "Inside review", "columns": 1 },
{ "title": "Umbrella Corps review", "columns": 2 }
]

https://i.ibb.co/fD1v4H9/Screenshot-2020...-57-57.png

As you can see from the above illustration, this article configuration creates a layout that has a gap in the third column of the first row.

Given the following article configuration, I need to write a piece of code that adjusts the layout so that it contains as few gaps as possible.

The final output should be rendered as an HTML document.

Article configuration:
[
{ "title": "Star Ocean review", "columns": 2 },
{ "title": "Lego Star Wars review", "columns": 2 },
{ "title": "Prison Architect review", "columns": 1 },
{ "title": "Inside review", "columns": 2 },
{ "title": "Umbrella Corps review", "columns": 2 },
{ "title": "Dino Dini's Kick Off review", "columns": 3 },
{ "title": "Trials of the Dragon review", "columns": 1 },
{ "title": "Mighty No. 9 review", "columns": 1 },
{ "title": "Edge of Nowhere review", "columns": 2 },
{ "title": "Guilty Gear Xrd Revelator review", "columns": 1 },
{ "title": "Sherlock Holmes review", "columns": 2 },
{ "title": "Mirror's Edge Catalyst review", "columns": 3 },
{ "title": "Kirby: Planet Robobot review", "columns": 3 },
{ "title": "Dangerous Golf review", "columns": 1 },
{ "title": "Teenage Mutant Turtles review", "columns": 1 },
{ "title": "The Warcraft movie review", "columns": 2 },
{ "title": "Overwatch Review", "columns": 2 },
{ "title": "The Witcher 3 review", "columns": 2 }
]
Reply
#2
some reading:
https://www.w3schools.com/css/css3_multiple_columns.asp
https://getbootstrap.com/docs/4.0/layout/grid/

I'd also take a look at:
https://blog.miguelgrinberg.com/post/the...ello-world
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to summarize an article that is stored in a word document on your laptop? Mikedicenso87 2 660 Oct-06-2023, 12:07 PM
Last Post: Mikedicenso87

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020