我有一个问题,我创建了一个div,并在其中放置了5个宽度已知的select项,但当我改变分辨率时,这些项开始移动到新行。如果有人帮我,我会吃饱的。

  #zone-geog{
        height:  100px;
        padding: 0px;
        white-space: nowrap;
        color : white;
      }
  #zone-geog .container{
          background: rgb(6,117,179);
          border-radius: 10px;
          white-space: nowrap;
      }
  #zone-geog .col-xs-12{
        height: 100%;
        padding: 0px;
        white-space: nowrap;
      }
  #zone-geog p{
        padding-left: 15px;
        font-family: 'Roboto Medium';
      }
  .select-prop{
        padding-left: 15px;
        padding-right: 2px;
        width: 263px;
      }
  .soft-padding{
        padding: 10px;
        border-radius: 10px;
      }
   .margin-zero{
        margin :0px;
      }

      <div id="zone-geog" class="row margin-zero hidden-xs">
        <div class="col-xs-12 margin-zero">
          <div id="menu-geog" class="row  soft-padding  margin-zero">
            <div class="container border-solid-black" style="display:inline-block;">
              <p>Zone Géographique</p>
              <div class="col-xs-2  center-block select-prop">
                <select class="form-control">
                  <option>BASSIN 1</option>
                </select>
              </div>
              <div class="col-xs-2  center-block select-prop">
                <select class="form-control">
                  <option>PERIMETRE1</option>
                </select>
              </div>
              <div class="col-xs-2  center-block select-prop">
                <select class="form-control">
                  <option>SECTEUR 1</option>
                </select>
              </div>
              <div class="col-xs-2  center-block select-prop">
                <select class="form-control">
                  <option>BLOC1</option>
                </select>
              </div>
              <div class="col-xs-2  center-block select-prop">
                <select class="form-control">
                  <option>PARCELLE3</option>
                </select>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div>

谢谢

最佳答案

您可以使用flexbox使它们始终在具有自动溢出的一行中
请参阅代码段:

#zone-geog {
  height: 100px;
  padding: 0px;
  white-space: nowrap;
  color: white;
}

#zone-geog .container {
  background: rgb(6, 117, 179);
  border-radius: 10px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow: auto;

}

#zone-geog .col-xs-12 {
  height: 100%;
  padding: 0px;
  white-space: nowrap;
}

#zone-geog p {
  padding-left: 15px;
  font-family: 'Roboto Medium';
}

.select-prop {
  padding-left: 15px;
  padding-right: 2px;
  width: 263px;
}

.soft-padding {
  padding: 10px;
  border-radius: 10px;
}

.margin-zero {
  margin: 0px;
}

<div id="zone-geog" class="row margin-zero hidden-xs">
  <div class="col-xs-12 margin-zero">
    <div id="menu-geog" class="row  soft-padding  margin-zero">
      <div class="container border-solid-black" style="">
        <p>Zone Géographique</p>
        <div class="col-xs-2  center-block select-prop">
          <select class="form-control">
                  <option>BASSIN 1</option>
                </select>
        </div>
        <div class="col-xs-2  center-block select-prop">
          <select class="form-control">
                  <option>PERIMETRE1</option>
                </select>
        </div>
        <div class="col-xs-2  center-block select-prop">
          <select class="form-control">
                  <option>SECTEUR 1</option>
                </select>
        </div>
        <div class="col-xs-2  center-block select-prop">
          <select class="form-control">
                  <option>BLOC1</option>
                </select>
        </div>
        <div class="col-xs-2  center-block select-prop">
          <select class="form-control">
                  <option>PARCELLE3</option>
                </select>
        </div>
      </div>
    </div>
  </div>
</div>
<div>

关于html - 防止在更改分辨率时选择元素包装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44799514/

10-09 14:35