Php 如何将此设置为中心<;ul>;?
到目前为止,我有以下代码:Php 如何将此设置为中心<;ul>;?,php,html,css,html-lists,centering,Php,Html,Css,Html Lists,Centering,到目前为止,我有以下代码: function changeGeoLoc($a,$b,$c){ echo "<ul style='list-style-type: none; display:inline;'>"; while(list(,$geoloc) = each($a) AND list(,$Details) = each($b)) { echo "<li style='list-style-type: none; display:inline; padding-rig
function changeGeoLoc($a,$b,$c){
echo "<ul style='list-style-type: none; display:inline;'>";
while(list(,$geoloc) = each($a) AND list(,$Details) = each($b)) {
echo "<li style='list-style-type: none; display:inline; padding-right:5px;'>$Details {$c->$geoloc} </li>";
}
echo "</ul>";
}
函数changeGeoLoc($a、$b、$c){
echo“”;
而(列表(,$geoloc)=每个($a)和列表(,$Details)=每个($b)){
echo“- $Details{$c->$geoloc}
”;
}
回声“
”;
}
这就产生了:
有没有人知道如何把上面的中心放在中间?
任何想法都值得赞赏
谢谢
更新:
我曾尝试将样式设置为块,并使用固定的with进行margin:0 auto,但这是一个问题,我需要它沿100%的宽度延伸,因为字段的IP、城市、地区、国家名称和国家代码将通过GeoLoc服务自动填写,因此,固定宽度(比如500px)不够大,因此它需要整个宽度,我希望它居中,因为如果有人查看我的网页,那里的信息不使用整个宽度,它将看起来更好居中。
我希望这是有意义的试试这个:
<ul style='list-style-type: none; display:block; width:500px; margin:0 auto;'>
试试这个:
<ul style='list-style-type: none; display:block; width:500px; margin:0 auto;'>
将ul
包装在div中,然后添加此CSS:
.className {
margin:0 auto;
}
HTML:
- 东西
将ul样式更改为
block
将ul
包装在div中,然后添加此CSS:
.className {
margin:0 auto;
}
HTML:
- 东西
如果您想在不提供固定宽度的情况下使ul内容居中,则将ul样式更改为“块”,最简单的方法可能是:
function changeGeoLoc($a,$b,$c){
echo "<ul style='list-style-type: none; text-align: center;'>";
while(list(,$geoloc) = each($a) AND list(,$Details) = each($b)) {
echo "<li style='list-style-type: none; display:inline; padding-right:5px;'>$Details {$c->$geoloc} </li>";
}
echo "</ul>";
}
函数changeGeoLoc($a、$b、$c){
echo“”;
而(列表(,$geoloc)=每个($a)和列表(,$Details)=每个($b)){
echo“- $Details{$c->$geoloc}
”;
}
回声“
”;
}
如果您想在不提供固定宽度的情况下将UL内容居中,最简单的方法可能是:
function changeGeoLoc($a,$b,$c){
echo "<ul style='list-style-type: none; text-align: center;'>";
while(list(,$geoloc) = each($a) AND list(,$Details) = each($b)) {
echo "<li style='list-style-type: none; display:inline; padding-right:5px;'>$Details {$c->$geoloc} </li>";
}
echo "</ul>";
}
函数changeGeoLoc($a、$b、$c){
echo“”;
而(列表(,$geoloc)=每个($a)和列表(,$Details)=每个($b)){
echo“- $Details{$c->$geoloc}
”;
}
回声“
”;
}
.className
需要定义宽度,以便边距:0自动
开始工作。.className
需要定义宽度,以便边距:0自动代码>开始工作。@Ryan好吧,那么不要使用列表,而只是一个文本-然后只将其与文本对齐:居中…@Ryan好吧,那么不要使用列表,而只是一个文本-然后只将其与文本对齐:居中。。。