使用CSS问题的样式

时间:2014-05-24 11:40:11

标签: html css

我希望我的评论输入文本框比表单中的其他字段大。我的添加表单中有以下代码:

<div class="divm centerdiv">
<?php echo $this->Form->create('Call'); ?>
    <fieldset>
        <legend><?php echo __('Add Call Details'); ?></legend>
            <?php

        echo $this->Form->input('call_date',array('required'=>false,'id'=>'datepicker','type'=>'text'));
        echo $this->Form->input('call_time', array('required'=>false));
        echo $this->Form->input('comments', array('required'=>false, 'id'=> 'comments'));
        echo $this->Form->input('next_call_date',array('required'=>false,'id'=>'datepicker2','type'=>'text'));
        echo $this->Form->input('customers_id', array('label' =>'Customer Name','options'=>$customers, 'label'=>'Customer Name', 'required'=>false));
        echo $this->Form->input('employees_id', array('label' =>'Employee name','options'=>$employees, 'label'=>'Employee name', 'required'=>false));

    ?>
    </fieldset>

<?php echo $this->Form->end(__('Submit')); ?>
</div>

我已为评论和样式表添加了ID,如下所示:

//some code
.divm
{
    width: 50%;

}
.centerdiv
{
    margin: 50px auto;

}
divm.comments{
    height: 20px;
    width: 20px;
}

//some code

我想将注释文本框的大小更改为比其他字段更大的大小。我试图通过在样式表中添加“divm.comments {}”部分来实现这一点,并且它似乎不起作用。可以有人帮忙吗?

2 个答案:

答案 0 :(得分:1)

您使用的是错误的(在这种情况下无效)选择器。它应该只是

#comments {
  height: 20px;
}

有关信息,您尝试选择标记名为divm(没有这样的东西)的元素的语法具有类名= comments

您可能一直在考虑的是选择输入id = = div内的注释与class = divm在这种情况下它应该是.divm #comments(注意空格)但是选择具有id的元素总是更高效(他们 - 或者至少应该 - 是独一无二的)

答案 1 :(得分:0)

您可以将#用于元素ID。 .用于课程。您的新样式表如下:

.divm
{ 
     width: 50%;

} 
.centerdiv
{ 
    margin: 50px auto;

}
#comments
{
    height: 20px;
    width: 20px;
}

注意:ID必须与仅一个元素相关,因此如果您想要多个评论字段,原始css将是正确的(除了.之前丢失的divm.comments )但你必须将comments设置为php中的class