在响应式布局上将divs相互定位

时间:2015-11-06 14:20:06

标签: html css responsive-design

我有这个html和css:

<div class="section group">
    <div class="col span_1_of_3">
     <div id="busqueda">
         content
      </div>
    This is column 1

    </div>
    <div class="col span_1_of_3">
    This is column 2
<div id="busqueda">
         content
      </div>
    </div>
    <div class="col span_1_of_3">
    This is column 3
<div id="busqueda">
         content
      </div>
    </div>
</div>

的CSS:

/*  SECTIONS  */
.section {
    clear: both;
    padding: 0px;
    margin: 0px;
}

/*  COLUMN SETUP  */
.col {
    display: block;
    float:left;
    margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }

/*  GROUPING  */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }

/*  GRID OF THREE  */
.span_3_of_3 { width: 100%; }
.span_2_of_3 { width: 66.13%; }
.span_1_of_3 { width: 32.26%; }

/*  GO FULL WIDTH BELOW 480 PIXELS */
@media only screen and (max-width: 480px) {
    .col {  margin: 1% 0 1% 0%; }
    .span_3_of_3, .span_2_of_3, .span_1_of_3 { width: 100%; }
}

我的问题是,然后我在每个.span里面都有几个div,当我调整它们重叠的窗口时,我希望它们堆叠,当我调整窗口大小时,一个在另一个下面,该div的css为:

#busqueda {
    /*white-space: nowrap;*/
  display: inline-block;
  background-color: #FFFFFF;
  color: #000000;
  border: 5px solid #6D6D6D;
  padding: 19px;
  font-family: 'trebuchet ms';
  font-style: oblique;
  font-weight: normal;
  font-variant: normal;
  border-radius: 13px;
  margin-right: 55%;
  border-color:#fd8a17;
  margin-bottom:50px;
}

我应该做些什么来实现这一目标?我试过让它们无效。

1 个答案:

答案 0 :(得分:0)

似乎第一列的html与其他两列的html有所不同。 所以我在这里做了调整:https://jsfiddle.net/qrbcf8ne/1/ 以下是更改的代码,我还在每个范围中再添加一个div:

<div class="section group">
    <div class="col span_1_of_3">This is column 1
        <div id="busqueda">content11</div>
        <div id="busqueda">content22</div>
    </div>
    <div class="col span_1_of_3">This is column 2
        <div id="busqueda">content21</div>
        <div id="busqueda">content22</div>
    </div>
    <div class="col span_1_of_3">This is column 3
        <div id="busqueda">content31</div>
        <div id="busqueda">content32</div>
    </div>
</div>

希望这有帮助。