与内联块未对齐(其他元素被推下)

发布于 2024-12-15 12:35:03 字数 2218 浏览 2 评论 0原文

我正在尝试将小盒子排成一行。这些盒子每个里面有大约 2 个元素。在某些情况下,第一个元素的文本太多,以至于它分成两行。如果发生这种情况,该特殊行中的所有其他块如下所示。

长话短说,这是一个例子: http://jsfiddle.net/PMRQ5/

如果您调整 HTML 字段的大小,您就会明白我的意思。有人可以帮忙吗?

.songlist .even {
  background: #c2e4fa;
  background: -moz-linear-gradient(top, #d9eefc, #c2e4fa);
  margin-right: 5px;
}
.songlist .odd {
  background: #faf4c2;
  background: -moz-linear-gradient(top, #fcf8d9, #faf4c2);
  margin-right: 5px;
}
.songlist .itemBox {
  font-size: 11px;
  width: 220px;
  min-height: 100px;
  clear: both;
  padding: 5px;
  margin: 5px 10px 5px 10px;
  display: inline-block;
  position: relative;
  border-radius: 4px;
}
.songlist .itemBox .title {
  font-weight: bold;
  font-size: 16px;
}
.songlist .itemBox .artist {
  clear: left;
  font-size: 11px;
}
.songlist .itemBox .titlerating {
  bottom: 10px;
  left: 10px;
  position: absolute;
}
.songlist .itemBox .dance {
  bottom: 5px;
  right: 10px;
  position: absolute;
}
<div class='songlist'>
  <div class='itemBox even'>
    <div class='cover'></div>
    <div class='title'>You and you</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
  <div class='itemBox odd'>
    <div class='title'>The Queen's lace hankerchief waltz</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
  <div class='itemBox even'>
    <div class='cover'></div>
    <div class='title'>Voices of spring</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
  <div class='itemBox odd'>
    <div class='cover'></div>
    <div class='title'>Roses from the south</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
</div>

I'm trying to align small boxes in a row. These boxes have something like 2 elements in each. In some cases, the first element is so "much" text, that it splits into 2 lines. If this happens, all other blocks in this special line are shown below.

Long story short, here is the example:
http://jsfiddle.net/PMRQ5/

If you resize the HTML field, you can see what I mean. Can somebody help?

.songlist .even {
  background: #c2e4fa;
  background: -moz-linear-gradient(top, #d9eefc, #c2e4fa);
  margin-right: 5px;
}
.songlist .odd {
  background: #faf4c2;
  background: -moz-linear-gradient(top, #fcf8d9, #faf4c2);
  margin-right: 5px;
}
.songlist .itemBox {
  font-size: 11px;
  width: 220px;
  min-height: 100px;
  clear: both;
  padding: 5px;
  margin: 5px 10px 5px 10px;
  display: inline-block;
  position: relative;
  border-radius: 4px;
}
.songlist .itemBox .title {
  font-weight: bold;
  font-size: 16px;
}
.songlist .itemBox .artist {
  clear: left;
  font-size: 11px;
}
.songlist .itemBox .titlerating {
  bottom: 10px;
  left: 10px;
  position: absolute;
}
.songlist .itemBox .dance {
  bottom: 5px;
  right: 10px;
  position: absolute;
}
<div class='songlist'>
  <div class='itemBox even'>
    <div class='cover'></div>
    <div class='title'>You and you</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
  <div class='itemBox odd'>
    <div class='title'>The Queen's lace hankerchief waltz</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
  <div class='itemBox even'>
    <div class='cover'></div>
    <div class='title'>Voices of spring</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
  <div class='itemBox odd'>
    <div class='cover'></div>
    <div class='title'>Roses from the south</div>
    <div class='artist'>101 Strings Orchestra</div>
    <div class='clear'></div>
  </div>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

马蹄踏│碎落叶 2024-12-22 12:35:03

http://jsfiddle.net/PMRQ5/1/

添加vertical-align: top< /code> 或 vertical-align:bottom 到框,取决于您想要的。

http://jsfiddle.net/PMRQ5/1/

Add vertical-align: top or vertical-align: bottom to the box, depends on what you want.

烈酒灼喉 2024-12-22 12:35:03
.songlist .even {
  background:#c2e4fa;
  background:-moz-linear-gradient(top,#d9eefc,#c2e4fa);
  margin-right:5px;
}
.songlist .odd {
  background:#faf4c2;
  background:-moz-linear-gradient(top,#fcf8d9,#faf4c2);
  margin-right:5px;
}
.songlist .itemBox {
  font-size:11px;
  width:220px;
  min-height:100px;
  clear:both;
  padding:5px;
  margin:5px 10px 5px 10px;
  display:inline-block;
  position:relative;
  border-radius:4px;
  vertical-align: bottom;
}
.songlist .itemBox .title {
  font-weight:bold;
  font-size:16px;
}
.songlist .itemBox .artist {
  clear:left;
  font-size:11px;
}
.songlist .itemBox .titlerating {
  bottom:10px;
  left:10px;
  position:absolute;
}
.songlist .itemBox .dance {
  bottom:5px;
  right:10px;
  position:absolute;
}
<div class='songlist'>
    <div class='itemBox even'>
        <div class='cover'></div>        
        <div class='title'>You and you</div>
        <div class='artist'>101 Strings Orchestra</div>        
        <div class='clear'></div>
    </div>                    
    <div class='itemBox odd'>    
        <div class='title'>The Queen's lace hankerchief waltz</div>
        <div class='artist'>101 Strings Orchestra</div>        
        <div class='clear'></div>
    </div>
    <div class='itemBox even'>
        <div class='cover'></div>    
        <div class='title'>Voices of spring</div>
        <div class='artist'>101 Strings Orchestra</div>    
        <div class='clear'></div>
    </div>                    
    <div class='itemBox odd'>
        <div class='cover'></div>        
        <div class='title'>Roses from the south</div>
        <div class='artist'>101 Strings Orchestra</div>    
    <div class='clear'></div>
    </div>
</div>

.songlist .even {
  background:#c2e4fa;
  background:-moz-linear-gradient(top,#d9eefc,#c2e4fa);
  margin-right:5px;
}
.songlist .odd {
  background:#faf4c2;
  background:-moz-linear-gradient(top,#fcf8d9,#faf4c2);
  margin-right:5px;
}
.songlist .itemBox {
  font-size:11px;
  width:220px;
  min-height:100px;
  clear:both;
  padding:5px;
  margin:5px 10px 5px 10px;
  display:inline-block;
  position:relative;
  border-radius:4px;
  vertical-align: bottom;
}
.songlist .itemBox .title {
  font-weight:bold;
  font-size:16px;
}
.songlist .itemBox .artist {
  clear:left;
  font-size:11px;
}
.songlist .itemBox .titlerating {
  bottom:10px;
  left:10px;
  position:absolute;
}
.songlist .itemBox .dance {
  bottom:5px;
  right:10px;
  position:absolute;
}
<div class='songlist'>
    <div class='itemBox even'>
        <div class='cover'></div>        
        <div class='title'>You and you</div>
        <div class='artist'>101 Strings Orchestra</div>        
        <div class='clear'></div>
    </div>                    
    <div class='itemBox odd'>    
        <div class='title'>The Queen's lace hankerchief waltz</div>
        <div class='artist'>101 Strings Orchestra</div>        
        <div class='clear'></div>
    </div>
    <div class='itemBox even'>
        <div class='cover'></div>    
        <div class='title'>Voices of spring</div>
        <div class='artist'>101 Strings Orchestra</div>    
        <div class='clear'></div>
    </div>                    
    <div class='itemBox odd'>
        <div class='cover'></div>        
        <div class='title'>Roses from the south</div>
        <div class='artist'>101 Strings Orchestra</div>    
    <div class='clear'></div>
    </div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文