css - CSS栏中包含图片的文字-LMLPHP

这是我的电子书应用程序。列的高度会有所不同。因此,图像位置很难预测。我使用-webkit-column-break-before:总是;防止图像在列之间划分。但是此方法留有空白空间。

是否可以用第二行中的最后一行填充空白?你怎么看?

https://jsfiddle.net/rg9kvnys/

#mydiv{
  width:1000px;
  height:200px;
  -webkit-column-width:200px;
  border-style:solid;
 }

#image{
  box-sizing:border-box;
  border-style:solid;
  border-color:red;
  background-color:lightblue;
  height:100%;
  -webkit-column-break-before: always;
}

最佳答案

我可能评论得太快了。您需要float #image



#mydiv {
  width: 1000px;
  height: 200px;
  -moz-column-width: 200px;
  -webkit-column-width: 200px;
  column-width: 200px;
  border-style: solid;
  /* eventually */
  -moz-column-fill: balance;
  -webkit-column-fill: balance;
  column-fill: balance;
}

#image {
  box-sizing: border-box;
  border-style: solid;
  border-color: red;
  background-color: lightblue;
  float: left;
  -moz-column-break-before: always;
  -webkit-column-break-before: always;
  column-break-before: always;
}

<div ID="mydiv">
  But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of
  human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely
  <div ID="image"><img src="http://lorempixel.com/190/190/people" /></div> painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but occasionally circumstances occur in which toil and pain can procure him some
  great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences,
  or one who avoids a pain that produces no resultant pleasure?But I must explain to you how all this mistaken idea of denouncing of a pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings
  of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are
  extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which
  of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant
  pleasure?
</div>





https://jsfiddle.net/rg9kvnys/3/

或没有设置heightcolumn-fill也可以方便使用https://jsfiddle.net/rg9kvnys/2/

关于css - CSS栏中包含图片的文字,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42322116/

10-17 02:53