溢出:溢出时左侧的内容被隐藏,设置为自动

时间:2018-12-10 13:00:32

标签: html css flexbox bootstrap-4 overflow

我正在尝试通过使用固定宽度和溢流来显示与计算机和移动设备中相同的box of content

:root {
    --box: rgb(20, 33, 150);
    --box1: rgb(55, 75, 255);
    --background: rgb(147, 158, 255);
}

body {
    -webkit-font-smoothing: antialiased;
    font-family: "Open Sans";
    font-weight: 400;
    background-color: var(--background);
}

.squad-table>.col-12 {
    border: 2px solid var(--background);
    display: flex;
    justify-content: center;
    overflow-x: auto;
}


.wrapper {
    width: 1000px;
    display: flex;
    justify-content: space-between;
}

.wrapper>.row {
    width: 500px;
    margin:3px; 
}


.box {
    background-color: var(--box);
    font-size: 1.2rem;
    color: #fff;
}

.squad-box {
    padding-bottom: 15px;
    padding-top: 15px;
    background-color: var(--box1);


}

.count-box {
    text-align: left;
    -webkit-border-top-right-radius: 30px;
    -moz-border-radius-topright: 30px;
    border-top-right-radius: 30px;
    background-color: var(--box1);

}


.team-box {
    display: flex;
    justify-content: center;
}

.team-box-inner {
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--box);
}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet"> -->
    <!-- <link rel="stylesheet" href="css/bootstrap.min.css"> -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
        crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css">
    <title>Learn HTML</title>
</head>

<body>
    <div class="container">

        <div class="row test">
            <div class="col-12 mx-auto">
                <h1 class=" display-1 text-center">Squad</h1>
            </div>
        </div>

        <div class="row squad-table">
            <div class="col-12">
                <div class="wrapper">

                    <div class="row box text-center">
                        <div class="col-4 count-box">Team 1</div>
                        <div class="col-8 space-box">space</div>
                        <div class="col-12 squad-box">
                            <div class="row">
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row box text-center">
                        <div class="col-4 count-box">Team 1</div>
                        <div class="col-8 space-box">space</div>
                        <div class="col-12 squad-box">
                            <div class="row">
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                                <div class="col-3 team-box">
                                    <div class="team-box-inner">name</div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
    </div>



    <!-- JS files -->
    <!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="js/bootstrap.min.js"></script> -->
</body>

</html>
这里的问题是溢出,当屏幕尺寸小于1000px时,它在左侧隐藏了一部分内容,这很奇怪,我不知道发生了什么。

是因为引导程序,flex还是溢出?

注意:我使用了Bootstrap 4.1.3

1 个答案:

答案 0 :(得分:0)

您只需为此

.squad-table>.col-12 {
    border: 2px solid var(--background);
    display: flex;
    justify-content: left;
    overflow-x: auto;
}

因为它的起始中心。您向左更改位置。