K
K
keche2017-02-23 13:30:53
css
keche, 2017-02-23 13:30:53

How to make background image rubber?

There is a background image. How to make it shrink and grow depending on browser width, resolution? Here is the codepen.io/Keche/pen/MpWwaN

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Ankhena, 2017-02-23
@Ankhena

background-size with values ​​cover , contain or 100% 100% depending on the desired behavior.

M
Maxim Timofeev, 2017-02-23
@webinar

So you have it. Only possible background-position: 50% 50%;
If you want to enter it completely, then not cover but contain.

A
Anton Mashletov, 2017-11-01
@Chetson

const categories = [
    { id: 1, name: 'name 1', parent: null },
    { id: 2, name: 'name 2', parent: 1 },
    { id: 3, name: 'name 3', parent: 6 },
    { id: 4, name: 'name 4', parent: 5 },
    { id: 5, name: 'name 5', parent: 6 },
    { id: 6, name: 'name 6', parent: null },
    { id: 7, name: 'name 7', parent: null }
];

function buildTree(items, parent) {
    parent = parent || null;
    let result = [];

    items.forEach((item) => {
        if (item.parent === parent) {
            result.push(item);
            item.children = buildTree(items, item.id);

            if (!item.children.length) {
                delete item.children;
            }
        }
    });
    
    return result;
}
// todo: не обходить уже добавленные
console.log(buildTree(categories));

I
ivanovSP, 2017-11-01
@ivanovSP

How to build a tree based on parent?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question