如何使块从新位置继续

时间:2018-12-20 10:20:08

标签: html css

大家好,我有个主意,但我不知道该怎么做。

第二个div的长度是自动的p,我想自动换行div

enter image description here

1 个答案:

答案 0 :(得分:0)

这可以通过将一些宽度设置为“ first-div”并设置为“ float:left”来实现。这样剩余的空间将分配给“ second-div”。在此处检查示例CSS。假设第一个div的类为“ first-div”:

.first-div {
  width: 300px;
  float: left;
  background-color: yellow;
}

请参见工作示例:

div {
  margin: 0 10px;
  padding: 0 10px;
  text-align: justify;
}

.border {
  border: 1px solid #777;
}

.first-div {
  width: 300px;
  float: left;
  background-color: yellow;
}
<div>
  <div class="first-div border">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit quis perferendis atque voluptatem iste non ex voluptatibus rem architecto laboriosam fugiat dolorum aspernatur nulla doloribus harum nostrum labore, id iure!
  </div>
  <div class="second-div">
    <p>
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit quis perferendis atque voluptatem iste non ex voluptatibus rem architecto laboriosam fugiat dolorum aspernatur nulla doloribus harum nostrum labore, id iure! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit quis perferendis atque voluptatem iste non ex voluptatibus rem architecto laboriosam fugiat dolorum aspernatur nulla doloribus harum nostrum labore, id iure!
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit quis perferendis atque voluptatem iste non ex voluptatibus rem architecto laboriosam fugiat dolorum aspernatur nulla doloribus harum nostrum labore, id iure!
      Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sit quis perferendis atque voluptatem iste non ex voluptatibus rem architecto laboriosam fugiat dolorum aspernatur nulla doloribus harum nostrum labore, id iure!
    </p>
  </div>
</div>