【问题标题】:HTML CSS form (combobox) vertical alignment in block_head division块头分割中的 HTML CSS 表单(组合框)垂直对齐
【发布时间】:2013-05-10 19:32:12
【问题描述】:

EDIT4:问题似乎已经解决了。当我在处理代码的另一部分时,组合框突然正确对齐。我不知道为什么它正常工作,但是,嘿,它有效! :D 我现在可以将其标记为 SOLVED

我有一个表单(组合框),就在一个块分区中的一个块头分区中的一个 h1 标题旁边,它可以完美地工作。我能够使用 CSS 文件将其对齐到我想要的位置。

另一方面,我在 block_head 的底部有另一个相同放置的组合框(我的意思是,我基本上使用了相同的代码),CSS 修改不会使它移动,除了 float : left/对。

这里有一些代码解决了这个问题。

效果不错的组合框:

<div class = "block">
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        <h1>Métriques d'utilisation</h1>
    </div>
    <div class="block_content">
        <!--Bloc CLIENT X-->
        <div class="block small left">
            <div class="block_head">
                <div class="bheadl"></div>
                <div class="bheadr"></div>
                <h2>
                    Client : 
                </h2>
                <form method = "post" action="#" name = "clientForm">
                    <p>
                        <select name = "client" onchange="clientForm.submit();">
                        <?php                       
                            foreach($_SESSION['clientList'] as $client) {
                                $selected = ($client == $_SESSION['currentClient']) ? 'selected = "selected"' : '';
                                echo "<option value = $client $selected>$client</option>";
                            }
                        ?>
                        </select>
                    </p>
                </form>
            </div>
...

出现错误的组合框:

<div class = "block">
    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>
        <h1>Tests</h1>
        <form id="branch" class="branch" method="post" action="#">
            <p>
                <select onchange="changeBranch(this.value)">
                <?php
                    $app->branch = $this->currentBranch;

                    foreach($GLOBALS['branchList'] as $entry) {
                        $selected = ($entry == $branch) ? 'selected="selected"' : '';
                        echo "<option value=\"{$entry}\" {$selected}>{$entry}</option>\n";
                    }
                ?>
                </select>
            </p>
        </form>
        <?php
            //Afficher la sélection de la branche
            //$app->showBranchForm();
        ?>
    </div>
...

block_head 的 CSS 代码:

.block .block_head {
    height: 54px;
    line-height: 54px;
    background: url(../images/bhead.gif) 0 0 repeat-x;
    overflow: hidden;
    }

.block .block_head .bheadl {
    width: 20px;
    height: 54px;
    float: left;
    background: url(../images/bheadl.gif) top left no-repeat;
    }

.block .block_head .bheadr {
    width: 20px;
    height: 54px;
    float: right;
    background: url(../images/bheadr.gif) top right no-repeat;
    }

.block .block_head h1 {
    font-family: "Trebuchet MS", Arial, sans-serif;
    font-size: 25px;
    font-weight: bold;
    text-transform: uppercase;
    color: #555;
    text-shadow: 1px 1px 0 #fff;
    float: left;
    }

.block .block_head h2 {
    font-family: "Trebuchet MS", Arial, sans-serif;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    color: #555;
    text-shadow: 1px 1px 0 #fff;
    float: left;
    }

.block .block_head ul {
    float: right;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #fff;
    }

.block .block_head ul li {
    display: inline;
    padding: 3px 0;
    padding-left: 20px;
    background: url(../images/phs.gif) 7px center no-repeat;
    }

.block .block_head ul li.nobg { background: none; }

.block .block_head ul li a {
    text-decoration: none;
    color: #666;
    outline: none;
    }

.block .block_head ul li.active a { color: #888; }
.block .block_head ul li a:hover { color: #008ee8; }

.block .block_head form {
    float: left;
    padding: 17px 10px;
    height: 34px;
    line-height: 24px;
    }

.block .block_head form .text {
    width: 129px;
    height: 15px;
    padding: 5px 10px 5px 25px;
    border: 0;
    font-size: 11px;
    color: #999;
    margin: 0;
    background: url(../images/srch.gif) left center no-repeat;
    }

.block .block_head form .text:focus {
    color: #666;
    background: url(../images/srch_.gif) left center no-repeat;
    }

.block .block_head select {
    text-transform: none;
    }

谁能指导我如何解决这个问题?

正如我所提到的,我尝试使用 CSS 文件,但它没有做任何事情。 我还尝试将表单移动到不同的 block_heads。

我会发布图片,但我需要 moar 声誉 -_-'

谢谢!

编辑:得到一些问题图片的链接:

Good combobox

Bad combobox

EDIT2:添加了完整的 block_head CSS 代码

EDIT3:撞!

EDIT4:问题似乎已经解决了。当我在处理代码的另一部分时,组合框突然正确对齐。我不知道为什么它正常工作,但是,嘿,它有效! :D 我现在可以将此标记为已解决

【问题讨论】:

    标签: php css forms html


    【解决方案1】:

    我本来想在评论中问这个问题,但我目前的声誉不允许我这样做:( 您是否有指向此示例的链接,因为很难理解您的问题是什么,或者如果您没有,甚至发布工作中的两组 CSS 和损坏的一组。他们俩是不是要并排出现?例如

    ===H1=== +++Combo+++

    编辑:

    感谢您提供额外的屏幕截图。我认为这是因为围绕选择的“P”标签而发生的。尝试从 P 中删除边距:

    .block .block_head form p {
    margin: 0;
    }
    

    参见此处的示例:

    http://jsfiddle.net/XBdeL/2/

    【讨论】:

    • 这里,我在原帖中添加了2个问题图片的链接!
    • an h1 也是块级标签,与块类名称不同。所以添加.block .block_head h1 {display:inline;} 可能会有所帮助
    • 我看到了你的例子的不同之处,添加你的代码确实使它正确。但是,当我在 jsfiddle 中添加完整的 block_head 代码时,效果很好。我编辑了我的 OP 以添加完整的 CSS 代码。
    • 抱歉有点困惑您还有问题吗?
    • 是的,我仍然得到与这两个图像相同的结果。我的意思是我只测试了我在原始帖子中的两个 CSS 代码块,结果并没有对齐。当我在 CSS 文件中添加 COMPLETE CSS 代码时,组合框对齐了。因此,我将完整的 CSS 代码添加到原帖中! ;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-28
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-23
    • 2012-10-24
    相关资源
    最近更新 更多