I
I
Ilya2019-09-29 19:35:17
Python
Ilya, 2019-09-29 19:35:17

How to make grid layout so that elements occupy a certain number of columns, regardless of position?

I have a block of 15 identical elements. I laid it out in 5 column grids:
5d90d8c008f52202712045.png
I want to achieve the same effect, only with 20 columns: grid-template-columns: repeat(20, 1fr);. grid-areaI do not want to manually set the elements . Maybe there is another option? For example, some property grid-spacefor the number of columns occupied, regardless of the position.
Sandbox

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Neyury, 2018-06-01
@dr4k

You can simplify your code like this

goods = ['Товар1', 'Товар2', 'Товар3', 'Товар4', 'Товар5', 'Товар6', 'Товар7', 'Товар8', 'Товар9', 'Товар10', 'Товар11', 'Товар12']

@bot.message_handler(func=lambda mess: "Продукция1" == mess.text, content_types=['text'])
def handle_text(message):
    keyboard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True, one_time_keyboard=False)

    for goods_item in goods:
        keyboard.row(goods_item)

    bot.send_message(message.from_user.id, "Выберите товар", reply_markup=keyboard)

@bot.message_handler(func=lambda mess: mess.text in goods, content_types=['text'])
def handle_text(message):
    keyboard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True, one_time_keyboard=False)

    if message.text in goods:
        bot.send_message(message.chat.id, "", reply_markup=keyboard )

Accordingly, you can dynamically define the goods array as you wish, form other lists, etc.
There are a lot of storage options, which one to choose depends on the method of placing the bot and the method of obtaining the initial data. It can be a txt, csv, json, xml, or python object file saved via shelve or pickle modules, or a sqlite database, or a complete database.
UPD:
The functions are called the same, you need to give them different names

O
origami1024, 2019-09-29
@sidorchik

.grid__item{
  grid-column: span 3;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question