为什么我的CSS需要一些额外的无用代码才能运行

时间:2017-04-11 12:06:55

标签: html css

所以我使用HTML和CSS制作一个简单的用户输入表单。我在网上找到了一个很好的CSS表单设计,并决定将其改编为我的表单。当我删除一些不必要的类时,我的HTML页面不需要CSS的选择器,我注意到CSS没有应用于我的提交按钮。如果我保留额外的类,即使它是空的,按钮的CSS也会被应用,但如果我完全删除它,那么按钮CSS会失败吗?

我可以在此处找到我获得CSS的网站的原始代码,使用表单样式5:Form Style 5

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="UserInput_CSS.css">

 <script type="text/javascript">
function validateForm() {
    alert("I am called");
    var fname = document.myForm.fname.value;
    var lname = document.myForm.lname.value;
    var age = document.myForm.age.value;
    //var expr = new RegExp(/^[a-zA-Z]+$/g);
    var expr = /^[a-zA-Z]+$/m;

    if(fname == "" || !isNaN(fname) || !expr.test(fname)) // || fname == NULL || fname== "(null)", !fname.match(expr)   
    {
        alert( "Please enter proper First Name" );
            document.myForm.fname.focus() ;
            return false;
    }

    if(lname == "" || !isNaN(lname) || !expr.test(lname)) // || lname == NULL || lname== "(null)", !lname.match(expr), !/^[a-zA-Z]+$/g.test(lname), !expr.test(lname)
    {
        alert( "Please enter proper Last Name" );
            document.myForm.lname.focus() ;
            return false;
    }

    if(age == "" || age == 0 || age<0 || age >122 || isNaN(age))
    {
        alert( "Please enter proper Age" );
            document.myForm.age.focus() ;
            return false;
    }
    return true;
}
</script>
</head>
<body>
<div class="form-style-5">
<form name="myForm" action="/itrade/user/CGI_Test.exe?action=submt" method="post" onsubmit="return validateForm();"> <!--onsubmit="return validateForm()"-->
<fieldset>
<legend>Candidate Info</legend>
First Name: <input type="text" name="fname" placeholder="First Name *"><br>
Last Name: <input type="text" name="lname" placeholder="Last Name *"><br>
Age: <input type="text" name="age" placeholder="Age *"><br>
<input type="submit" value="submit"> <!--onclick = "return validateForm();"-->
</fieldset>
</form>
</div>
</body>
</html>
an_letters = "aefhilmnorsxAEFHILMNORSX"
word = input("I will cheer for you! enter a word:")
times = int(input("Enthusiasm level (1-10):"))
i = 0
while i < len(word):
    char = word[i]
    if char in an_letters:
        print("Give ma an " + char + "! " + char)
    else:
        print("Give ma a " + char + "! " + char)
    i += 1
print("What does that spell?")
for i in range(times):
    print(word, "!!!!")

1 个答案:

答案 0 :(得分:4)

语法不正确,因为你有一个没有左括号或标识符的右括号:

    background: #1abc9c;
    color: #fff;
    height: 30px;
    width: 30px;
    display: inline-block;
    font-size: 0.8em;
    margin-right: 4px;
    line-height: 30px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255,255,255,0.2);
    border-radius: 15px 15px 15px 0px;
}

删除空样式(这有助于'取消'破解'CSS)导致按钮的下一个样式中断。