I have the following code. It's essentially a simple grid view that uses <ul>
and <li>
tags. I wanted to make it responsive such that the <li>
elements are always centered no matter what the width of the screen is. How can I do so? I've tried setting the padding-left
and padding-right
as percentages, however it doesn't work. Right now if I adjust the width of the screen it doesn't always stay centered.
问问题
601 次
4 回答
4
只需添加text-align: center
到父级<ul>
于 2013-09-16T06:52:54.250 回答
0
于 2013-09-16T07:00:07.603 回答
0
添加这个类:
ul.search-results{
width:100%;
}
并更新这个类:
ul.search-results li {
border-right: 1px solid #cecdcb;
border-bottom: 1px solid #cecdcb;
border-top: 1px solid #fff;
list-style: none;
padding: 0;
display: inline-block;
vertical-align: top;
width:60%;
margin:0 20%;
text-align:center;
}
于 2013-09-16T07:00:37.610 回答
0
我将扩展上一个答案...
也将 UL 居中
#home-listing {
text-align: center;
width:80%; /*Pick Your Own Width*/
margin:16px auto;
}
于 2013-09-16T06:57:53.910 回答