A
A
annyeong12021-01-06 22:37:45
css
annyeong1, 2021-01-06 22:37:45

How to fix display: flex if it's not working properly?

I'm making a navigation menu, there was such a problem: display flex on the parent element does not distribute elements to the entire block. Here is the code:

HTML
5ff61178e1268777002436.png

LESS

.shop_slider {
    
    .top_title_line {
        min-height: 81px;
        background: linear-gradient(#ff6c22, #ff4616);
        display: flex;
        align-items: center;
        color: #fff;
        .fredoka_font();

        .shop_box_title {
            flex-grow: 1;
            text-align: center;
        }

        .left, .right {
            display: block;
            opacity: 50%;
        }
    }
}


css

.shop_slider .top_title_line {
  min-height: 81px;
  background: linear-gradient(#ff6c22, #ff4616);
  display: flex;
  align-items: center;
  color: #fff;
  font-family: 'Fredoka One', cursive;
}
.shop_slider .top_title_line .shop_box_title {
  flex-grow: 1;
  text-align: center;
}
.shop_slider .top_title_line .left,
.shop_slider .top_title_line .right {
  display: block;
  opacity: 50%;
}


JSFiddle - https://jsfiddle.net/2rc5k8z0/2/

Putting a display block on child elements doesn't help, nor does setting a width of 100% on the parent. 5ff610e2543e9033992345.png

I want so:5ff6125571156589452761.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Ezhgurov, 2021-01-06
@annyeong1

Well, the flex in top_title_line only affects the single nested shop_slider_navigation tag - it does n't affect the tags inside shop_slider_navigation in any way.
And to distribute the blocks inside the shop_slider_navigation, you need display: flex; and set flex settings for shop_slider_navigation.
PS In the question editor there is an insert code button - with which you can insert both HTML and CSS normally. Making HTML an image doesn't make sense and only hinders the responders.

S
samura95, 2021-01-06
@samura95

Wrap the left and right blocks in a wrapper and voila

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question