似乎没有控制css中的类标记

时间:2011-04-08 21:36:32

标签: html css

我有一个类声明为特定输入的错误捕获:

'<span class="catch">Error caught</span>';

我在标签的末尾标注了一下:

.catch{
    font-size: 20px;
    color: #ffffff;
    font-family: arial;
    margin: 150px 0px 0px 35px ;
}

边距属性只是占位符,但我试图将文本向下移动到此窗体的底部,但只能控制x轴,而不能控制y轴。这有什么方法吗?这是我的表单代码:

#main{ 
    width: 375px; 
    height: 150px; 
    background: url(images/formheader.png) 0 0 no-repeat; 
    margin:200px auto; 
    z-index: 1; 

}

如果我需要提供更多信息,还有额外的CSS。

编辑:

#main{ 
   width: 875px; 
   height: 350px; 
   background: url(images/form.png) 0 0 no-repeat; 
   margin:250px auto; 
   z-index: 1; 
 }

2 个答案:

答案 0 :(得分:5)

<span>是一个内联元素,只有x轴边距适用于内联元素。 将.catch设为display:block;

根据@Czechnology评论,将<span>更改为<div>比使用内联元素并将其设置为阻止更有意义。

答案 1 :(得分:0)

如果没有看到html,很难说出你想要做什么,但如果你想.catch出现在#main的底部,你可以使用类似的东西:

.catch{
    position: absolute;
    bottom: 0;
}
#main{ 
    position: relative;
    padding-bottom: 100px;    /* example to avoid content of #main to be under .catch */
}