Пожалуйста, помогите с позицией содержимого моего контейнера Flex Box в головоломке с медиа-запросами. - PullRequest
0 голосов
/ 12 февраля 2020

Flex box @ media query min-width; 1024px

Я использую flex box в медиа-запросе, используя следующий экран @media only (min-width: 1024px), чтобы расположить кнопки меню в двух столбцах. Моя проблема в том, что кнопки перемещаются далеко друг от друга, и я бы предпочел, чтобы они были ближе друг к другу. возможно ли иметь две колонки ближе друг к другу. Чтобы увидеть проблему, используйте приведенный ниже пример и посмотрите на экран размера рабочего стола. Я использовал жирные цвета, чтобы выделить столбцы при выравнивании содержимого. хотел бы получить помощь по этому вопросу, любой может предложить какой-то совет.

* {
    box-sizing: border-box;
    margin: 0 !important;
    padding: 0;
    text-align: center;
}

body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

h1 {
    font-weight: normal;
    text-align: center;
}

.col-1 {
    background: #663;
    -webkit-order: 1;
    order: 1;
    align-items: center;
    flex-wrap: wrap;
}

.col-2 {
    background: #663;
    -webkit-order: 2;
    order: 2;
    align-items: center;
}

.col-3 {
    -webkit-order: 3;
    order: 3;
    background: red;
}


/*Header top*/

.header {
    display: flex;
    justify-content: space-between;
    background: #633;
    padding: 10px 10px;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

.header,
.header-right {
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-wrap: wrap;
}

.header a {
    float: left;
    color: black;
    text-align: center;
    padding: 12px;
    text-decoration: none;
    font-size: 18px;
    line-height: 25px;
    border-radius: 4px;
}

.header a.logo {
    font-size: 25px;
    font-weight: bold;
    justify-content: center;
}

.header a:hover {
    color: black;
}

.logo {
    display: flex;
    align-items: flex-start;
    transition: background 250ms ease-in-out, transform 150ms ease;
    -webkit-appearance: none;
    -moz-appearance: none;
}

img {
    max-width: 100%;
    height: auto;
}

.home-button {
    display: inline-block;
    border: none;
    padding: 1rem 2rem;
    border-radius: 4px;
    text-decoration: none;
    background: dodgerblue;
    color: #ffffff;
    font-family: sans-serif;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background 250ms ease-in-out, transform 150ms ease;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.header-right {
    float: right;
}

a.home-button:hover,
a.home-button:focus {
    background: #434344;
}

@media only screen and (min-width: 300px) {
    .header,
    .header a,
    .home-button,
    .logo {
        display: flex;
        justify-content: flex-start;
        float: none;
        display: block;
        padding: 5px;
    }
}

.header-right {
    float: none;
    padding: 20px;
}

@media only screen and (max-width: 750px) {
    /*    Need to look at all screen sizes for this to work correctly. but
    good work so far*/
    .header,
    .header-right {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* end of header*/


/***********************************************
             **********************************************
             *********************************************/


/*   Back button CSS*/

.button {
    display: inline-block;
    border: none;
    padding: 1rem 2rem;
    border-radius: 4px;
    text-decoration: none;
    background: dodgerblue;
    color: #ffffff;
    font-family: sans-serif;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background 250ms ease-in-out, transform 150ms ease;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.button:hover,
.button:focus {
    background: #434344;
}

.button:focus {
    outline: 1px solid #fff;
    outline-offset: -4px;
}

.button:active {
    transform: scale(0.99);
}


/*  back button CSS end*/


/***********************************************
             **********************************************
             *********************************************/

.footer {
    -webkit-order: 4;
    order: 4;
    background: yellow;
    align-items: center;
    display: block;
}


/* Media Queries*/


/* For mobile phones: */


/* SMARTPHONES PORTRAIT */

@media only screen and (min-width: 300px) {
    .row,
    .col-1,
    .col-2,
    .col-3,
    .footer {
        display: flex;
        flex-direction: column;
    }
    .dropbtn {
        width: 110px;
    }
    .menu-button {
        margin: 10px 0 !important;
    }
}


/* SMARTPHONES LANDSCAPE */

@media only screen and (min-width: 480px) {
    .row,
    .col-1,
    .col-2,
    .col-3,
    .footer {
        display: flex;
        flex-direction: column;
    }
    .menu-button {
        margin: 10px 0 !important;
    }
}


/* TABLETS PORTRAIT */

@media only screen and (min-width: 750px) {
    .row,
    .col-1,
    .col-2,
    .col-3,
    .footer {
        display: flex;
        flex-direction: column;
    }
    .menu-button {
        margin: 10px 0 !important;
    }
}


/* TABLET LANDSCAPE / DESKTOP */

@media only screen and (min-width: 1024px) {
    .row,
    .col-1,
    .col-2,
    .col-3,
    .footer {
        -ms-flex: 50%;
        /* IE10 */
        flex: 0 1 auto;
        margin: 30px;
    }
    .menu-button {
        margin: 10px 0 !important;
    }
}

@media only screen and (min-width: 1024px) {
    .row {
        display: -ms-flexbox;
        /* IE10 */
        display: flex;
        justify-content: center;
    }
    .col-1 {
        display: flex;
        flex: 0 1 auto;
        justify-content: space-around;
        flex-flow: column wrap;
        background-color: magenta;
        height: 300px;
    }
}

.row {
    display: -ms-flexbox;
    /* IE10 */
    display: flex;
}

.menu-button {
    background-color: rgba(85, 100, 83, 0.8);
    padding: 20px 0;
    font-size: 30px;
    width: 200px;
    border-radius: 25px;
    box-shadow: 5px 5px 5px rgba(71, 69, 69, 0.787);
}

.menu-button:hover {
    box-shadow: 1px 1px 1px rgba(71, 69, 69, 0.787);
    color: black;
}

a {
    color: black;
    text-decoration: none;
}

a:hover {
    color: rgba(71, 69, 69, 0.787);
    text-decoration: none;
}
image
...