跨越内部的div

时间:2016-05-22 19:26:09

标签: html css

我在fiddle

中有这段代码

我想知道是否可以让div在文本中浮动,就像下面的文字一样?



.a {
  position: relative;
  width: 100px;
  height: 40px;
  background: red;
}

<span>Pause and play icons will automatically be attached to every mp3 song in text. Like this for example: </span>
<div class="a"></div><span> ut laoreet hendrerit mi. Nam vestibulum viverra diam. Nullam eros ipsum, rutrum ut, ultricies sed, congue sed, est. Pellentesque porttitor. Donec dictum urna eu mi. Maecenas in lorem.</span>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)

display:inline-blockvertical-align一起使用,因为您可以将其设置为更适合您。

评论用户:

这是有效的HTML,因为span兄弟div不是其父级。

.a {
  display: inline-block;
  vertical-align: middle;
  width: 100px;
  height: 40px;
  background: red;
}
<span>Pause and play icons will automatically be attached to every mp3 song in text. Like this for example: </span>
<div class="a"></div><span> ut laoreet hendrerit mi. Nam vestibulum viverra diam. Nullam eros ipsum, rutrum ut, ultricies sed, congue sed, est. Pellentesque porttitor. Donec dictum urna eu mi. Maecenas in lorem.</span>