I met some trouble with the property inline-block
我在内线区遇到了一些问题
It works fine, but When I fill one of my <li>
it does not put them all at the same level.
它工作得很好,但是当我填满其中一个
I wanted all to have the same size (width and height)= and the same vertical position
我想要所有的都有相同的尺寸(宽度和高度)=相同的垂直位置
Below is my css
下面是我的css
ul#display-inline-block-example,
ul#display-inline-block-example li {
/* Setting a common base */
margin-right: 10;
margin-top: 10;
padding: 0;
}
ul#display-inline-block-example li {
display: inline-block;
min-width: 121px;
min-height: 95px;
max-width: 121px;
max-height: 95px;
background: rgb(255,255,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(47%,rgba(246,246,246,1)), color-stop(100%,rgba(237,237,237,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%); /* W3C */
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 0 0 0 1px #fafafa inset, 0 1px 1px 0px #dddddd;
border: 1px solid #d5d5d5;
-webkit-box-shadow: 0 0 0 1px #fafafa inset, 0 1px 1px 0px #dddddd;
-moz-box-shadow: 0 0 0 1px #fafafa inset, 0 1px 1px 0px #dddddd;
text-align:center
}
and then the html
然后是html
<div class="main">
<ul id="display-inline-block-example">
<li><img src="images/history.png"></li>
<li>Item two</li>
<li>Item three</li>
<li>Item one</li>
<li>Item two</li>
<li>Item three</li>
</ul>
</div>
Anykind of help will be much appreciated
任何形式的帮助都将受到感激
2 个解决方案
#1
14
try
试一试
vertical-align: top
on your inline-block
li
elements
垂直对齐:在你的inline-block li元素上
also see this link :
也可以看看这个链接:
http://www.impressivewebs.com/inline-block/
http://www.impressivewebs.com/inline-block/
#2
1
vertical-align: top
is the one your searching for . and it should be used on the elements that need vertical alignment . not on parent
垂直对齐:顶部是你要搜索的。它应该用于需要垂直对齐的元素。而不是父母
and if u want to go further and have same margin between elements . independent of the number of elements . then have a look at this http://jsfiddle.net/JrZ3Z/1/
如果你想更进一步,在元素之间有相同的边距。与元素的数量无关。然后查看http://jsfiddle.net/JrZ3Z/1/
#1
14
try
试一试
vertical-align: top
on your inline-block
li
elements
垂直对齐:在你的inline-block li元素上
also see this link :
也可以看看这个链接:
http://www.impressivewebs.com/inline-block/
http://www.impressivewebs.com/inline-block/
#2
1
vertical-align: top
is the one your searching for . and it should be used on the elements that need vertical alignment . not on parent
垂直对齐:顶部是你要搜索的。它应该用于需要垂直对齐的元素。而不是父母
and if u want to go further and have same margin between elements . independent of the number of elements . then have a look at this http://jsfiddle.net/JrZ3Z/1/
如果你想更进一步,在元素之间有相同的边距。与元素的数量无关。然后查看http://jsfiddle.net/JrZ3Z/1/