简体   繁体   English

错误消息的CSS样式

[英]CSS styling for error messages

I have a div which has php code to echo out errors on a page, I want to add some style to error appearance which is going well except one problem, every attribute works fine but padding seems to be their even when errors are not called I am using javascript to call errors though the error message is called only when their is some error but padding for error div is always there on the page. 我有一个div ,它具有php代码以echo页面上的错误,我想为错误外观添加某种样式,除了一个问题外,它运行得很好,每个属性都可以正常工作,但是即使没有调用错误, padding似乎是它们的代表。我正在使用javascript调用错误,尽管仅当错误是某些错误时才调用错误消息,但错误div padding始终在页面上。 How to solve it out. 如何解决。

<div id="error"><?php echo $error; ?></div><br />

<style>
#error {
font-size:
background-color:
opacity:
color:
padding:
}
</style>

since your php code is embedded in your div tag , definitely whether the error is called or not does'nt matter. 由于您的php代码已嵌入div标签中,因此,是否调用该错误绝对无关紧要。 The padding will still be there. 填充仍将存在。 Apply the div within your php code, or just the padding css style in your php code. 在您的php代码中应用div,或者仅在您的php代码中应用padding css样式。

Before calling #error write css like this 在调用#error之前,像这样编写CSS

#error {
font-size:
background-color:
opacity:
color:
padding:
display:none;
}

Now when you are call that #error then make css as 现在,当您致电该#error然后使CSS为

#error {
display:block;
}

Now it will not take any space if error message is not there 现在,如果没有错误消息,它将不占用任何空间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM