Pergunta

I wanna make the dropdown list to appear in the center of the page. How do I do that?

Code:

echo '<div class="dropCenter" align="center">';        
echo '<label><SELECT name="projectDropdown" id="projectDropdown" class="projectSelect">'.'<br>';
echo '<OPTION VALUE=" ">'."".'</OPTION>';

while($row = oci_fetch_array($compCuttingResult,OCI_ASSOC)) {
     $projectName = $row ['PROJECT_NAME'];
     echo "<OPTION VALUE='$projectName'>$projectName</OPTION>";
}

echo '</SELECT></label><br />';
Foi útil?

Solução

First, remove all BR and LABEL tags from the HTML markup.
Next append a closind DIV tag at the end of the markup.

PHP Code

$html = null;
$html .= "<div class=\"dropCenter\">";
$html .= "<select id=\"projectDropDown\" name=\"projectDropDown\">";
$html .= "<option value=\"\"></option>";
while($row = oci_fetch_array($compCuttingResult,OCI_ASSOC)){
    $projectName = $row['PROJECT_NAME'];
    $html = sprintf("<option value=\"%s\">%s</option>", $projectName, $projectName);
}
$html .= "</select>";
$html .= "</div>";
print $html;

CSS Code

<style type="text/css">
    select.projectSelect{ width:280px; height:24px; margin:10px; }
    select.projectSelect option{line-height:24px;}
    div.dropCenter{ display:inline-block; position:absolute; width:300px; height:34px; margin-left:-150px; margin-top:-17px; background-color:#e0e0e0; border:1px solid #c0c0c0; }
</style>

Outras dicas

use the style to the first div

margin: 0px auto;

This should put the div in center

You can use this code

margin:auto;

<div class="dropCenter" style= 'margin:auto;'>

also you will have to check what are the divs you have above this. If there is no effect with above divs this would work fine.

External Inherited Style Sheets will also have an effect.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top