在奇数布局中对齐div

时间:2015-09-22 03:37:18

标签: html css

我正按照我附上的图片来调整我的div。

enter image description here

请原谅不好的涂鸦。

我已经尝试了一些方法来获得所需的布局,但是当我接近时,我的div会溢出。

这是My Fiddle

所有帮助非常感谢:)

              <div id="bigbox">
                <div id="box1">
                   <div id="innerbox1">

                     <div id="box-image">
                        <a href="course.html">
                            <p id="image-text">
                                Image text</p></a>
                    </div>


                 <div id="box2">
                   <div id="innerbox2">


                  <div id="box3">
                    <div id="innerbox3">



                         <div id="box-image2">
                            <a href="blog.html">
                            <p id="image-text2">
                                Image text</p></a>

                         </div>
                    <div id="box4">
                      <div id="innerbox4">
                        <div id="bluebox">
                    </div></div>
             </div>
          </div>

1 个答案:

答案 0 :(得分:0)

我不确定我为什么这样做,但是,这里是一个快速的刺。您可以根据需要调整高度和宽度。

http://codepen.io/scottstreit/pen/epzjBp

<div class="wrapper">
  <div class="col col1">
    <div class="box1">
      <img src="http://placehold.it/300x400" alt="Box 1" />
    </div>
    <div class="box3">
      <img src="http://placehold.it/300x100" alt="" />
    </div>
  </div>

  <div class="col col2">
    <div class="box2">
      <img src="http://placehold.it/300x600" alt="" />
    </div>
    <div class="box4">
      <p>Dreamcatcher Wes Anderson photo booth ugh, drinking vinegar Brooklyn ethical occupy. Single-origin coffee butcher next level ethical tofu mumblecore, Brooklyn umami High Life hella hoodie taxidermy four dollar toast. Farm-to-table cray fanny pack
        chillwave. Wayfarers ennui four loko next level yr banjo retro brunch, irony lumbersexual Kickstarter keffiyeh leggings semiotics.</p>
    </div>
  </div>
</div>

CSS

* {
  box-sizing: border-box;
  text-align: center;
}
.wrapper {
  width: 1024px;
  min-height: 1000px;
  border: 1px solid lime;
}
div.col {
  width: 50%;
  float: left;
  display: inline-block;
}