0

我有一个字母数组。添加样式后,数组从水平变为垂直。

这是代码:

$alphabetical_array = range('a','z');
function AddLinks($letter)
{
$title = strtoupper($letter);
$a = "<a href='alpha_search.php?letter=".$letter."' class='alphabtn'><font color='#FFFFFF'>".$title."</font></a>";
return($a);
}

$format_array = array_map("AddLinks", $alphabetical_array);
echo implode($format_array);

这是CSS:

.alphabtn {
    max-width:10px;
    text-decoration: none;
    position: relative;
    padding: 5px ;
    text-align:left;
    clear: both; 
    text-indent:0;
    display: block;
    font: bold 12px/14px Arial, Helvetica, sans-serif;
    text-transform: uppercase;
    color: #fff;
    border-radius: 4px;
    border: 1px solid #391b61;
    text-shadow: 1px 1px 1px #ccc;
    background: -moz-linear-gradient(top, #864fd3 0%, #553285 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#864fd3), color-stop(100%,#553285));
    background: -webkit-linear-gradient(top, #864fd3 0%,#553285 100%);
    background: -o-linear-gradient(top, #864fd3 0%,#553285 100%);
    background: -ms-linear-gradient(top, #864fd3 0%,#553285 100%);
    background: linear-gradient(to bottom, #864fd3 0%,#553285 100%);
    -pie-background: linear-gradient(#864fd3, #553285);
    -webkit-box-shadow: inset 0px 1px 1px 1px #a55aff;
    box-shadow: inset 0px 1px 1px 1px #a55aff;
    behavior: url(../login/_ui/js/PIE.htc);
}.alphabtn:hover {
    background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #553285), color-stop(1, #864fd3) );
    background:-moz-linear-gradient( center top, #553285 5%, #864fd3 100% );
    background: -moz-linear-gradient(top, #553285 0%, #864fd3 100%);
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#553285', endColorstr='#864fd3');
    background-color:#553285;
}.alphabtn:active {
    position:relative;
    top:1px;
}
4

3 回答 3

1

你有

clear: both;

设置在您的标签上。很确定这会导致

<a>

被视为块并换行。

尝试删除它。

于 2013-04-24T22:15:37.397 回答
1

display: block;在css中有。这将导致每个元素显示在自己的行上。删除它,其他一切都应该没问题。

于 2013-04-24T22:17:28.470 回答
0

改变

.alphabtn {
    max-width:10px;
    text-decoration: none;
    position: relative;
    padding: 5px ;
    text-align:left;
    clear: both; 
    text-indent:0;
    display: block;

.alphabtn {
    max-width:10px; //Why this line?
    text-decoration: none;
    position: relative;
    padding: 5px ;
    text-align:left;
    text-indent:0;
    display: inline-block; (or delete the row)
于 2013-04-24T22:19:05.740 回答