English 中文(简体)
一份三栏报纸刊登的许多剪辑
原标题:many divs in a 3-column newspaper layout
  • 时间:2010-11-08 12:40:16
  •  标签:
  • css

Currently I have a number of divs of undefined length/height. they contain a few hyperlinks as a list. The almost-desired effect is achieved by giving these divs float:left; width:150px; margin: 10px; However, in the scenario of the first div containing just 1 link, and the second div containing 10 I get the following result (numbers represent divs):

1  2  5
   3  6
   4  7
8

预期成果如下:

1  3  6          1  4  7
2  4  7    or    2  5  8
   5  8          3  6
最佳回答

有三个解决办法,每个办法都有问题。

首先,你可以对所有物品设定高度限制,或使用固定高度。 加上溢出财产,将使你有一个子网。

ul li {
    width: 200px;
    height: 200px;
    float: left;
    overflow: hidden;
}

或者,您可将<条码>div上载到三个不同的集装箱内,每个集装箱都单独浮动。 这还将给你三栏,但你可能需要做一些服务器,以确保每栏内容的高度均衡分布:

ul {
    float: left;
    width: 200px;
}

最后,有CSS3号插图,使你能够轻而易举地制造一栏,但根本得不到EE的支持。

ul {
   -moz-column-count: 3;
   -webkit-column-count: 3;
   column-count: 3;
}
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签