屏幕移动时按钮溢出 x 成行

Button overflow x in line when the screen is mobile

我有一行按钮。当我缩小屏幕时,我希望所有按钮保持一致并作为 overflow-x: scroll.

我的问题是缩小屏幕时,overflow x 有效,但按钮从屏幕中出来。

我该如何解决这个问题?谢谢

DEMO

代码

  <div class="row justify-content-center flex-nowrap myrow" style="margin-top: 160px;">
    <a style="color: #51CC8B;" class="btnP">PRG
      <span class="nav-link btn-glyphicon1">100</span>
    </a>
    <a style="color: #4981C2;" class="btnR">TRV
      <span class="nav-link btn-glyphicon">50</span>
    </a>
    <a style="color: #4981C2;" class="btnD">DN
      <span class="nav-link btn-glyphicon">21</span>
    </a>
  </div>

问题

已删除 row class 和 添加了 d-flex justify-content-md-center classes 并在下面添加 css

.myrow {
  overflow-x: auto;
}

.myrow {
  overflow-x: auto;
}

.btn-glyphicon {
  padding: 8px;
  line-height: 6px;
  text-align: center;
  border-radius: 16px;
  background: #ffffff;
  right: 0;
  position: absolute;
  background: #DBE7F4 0% 0% no-repeat padding-box;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  letter-spacing: 0;
  color: #4981C2;
}

.btn-glyphicon1 {
  padding: 8px;
  line-height: 6px;
  text-align: center;
  border-radius: 16px;
  background: #ffffff;
  right: 0;
  position: absolute;
  background: #DDF6E9 0% 0% no-repeat padding-box;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  letter-spacing: 0;
  color: #51CC8B;
}

.btnR {
  padding-right: 50px;
  padding-left: 8px;
  height: 24px;
  font-size: 13px;
  transition: all 0.3s ease 0s;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
  display: inline-block;
  display: flex;
  align-items: center;
  margin-right: 16px;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  line-height: 6px;
  letter-spacing: 0;
  color: #4981C2;
  -ms-border-radius: 16px;
  -o-border-radius: 16px;
  -moz-border-radius: 16px;
  -webkit-border-radius: 16px;
  border-radius: 16px;
  border-width: none;
  background: #ECF2F9;
  cursor: pointer;
  outline: none;
}

.btnP {
  padding-right: 50px;
  padding-left: 8px;
  height: 24px;
  font-size: 13px;
  transition: all 0.3s ease 0s;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
  display: inline-block;
  display: flex;
  align-items: center;
  margin-right: 16px;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  line-height: 6px;
  letter-spacing: 0;
  color: #51CC8B;
  -ms-border-radius: 16px;
  -o-border-radius: 16px;
  -moz-border-radius: 16px;
  -webkit-border-radius: 16px;
  border-radius: 16px;
  border-width: none;
  background: #EDFAF3;
  cursor: pointer;
  outline: none;
}

.btnD {
  padding-right: 50px;
  padding-left: 8px;
  height: 24px;
  font-size: 13px;
  transition: all 0.3s ease 0s;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
  display: inline-block;
  display: flex;
  align-items: center;
  margin-right: 16px;
  text-align: center;
  font-weight: bold;
  font-size: 13px;
  font-family: 'Noto Sans', sans-serif;
  line-height: 6px;
  letter-spacing: 0;
  color: #4981C2;
  -ms-border-radius: 16px;
  -o-border-radius: 16px;
  -moz-border-radius: 16px;
  -webkit-border-radius: 16px;
  border-radius: 16px;
  border-width: none;
  background: #ECF2F9;
  cursor: pointer;
  outline: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.css" rel="stylesheet"/>
<div class="d-flex justify-content-md-center flex-nowrap myrow" style="margin-top: 160px;">
  <a style="color: #51CC8B;" class="btnP">PRG
      <span class="nav-link btn-glyphicon1">100</span>
    </a>
  <a style="color: #4981C2;" class="btnR">TRV
      <span class="nav-link btn-glyphicon">50</span>
    </a>
  <a style="color: #4981C2;" class="btnD">DN
      <span class="nav-link btn-glyphicon">21</span>
    </a>
</div>