[英]Why is my CSS code not working in my HTML file?
我试图将CSS代码与HTML代码放在同一文件中,但是无法正确显示(我不想仅将CSS链接到HTML,我已经可以使用它了)。 我曾尝试复制和粘贴代码,但这不起作用。 当它在同一文件中时,我是否必须做不同的事情?
以下是相关代码:
<head>
<title> Example </title>
<style type="text/css">
input: textarea{
resize: none;
}
input[type=button]{//set the sizes for all of the input buttons
width: 5em;
height: 2em;
font-size: 15px;
font-weight: bold;
}
</style>
</head>
<body>
<form id = "mainForm" name="mainForm" method="get" action="" onsubmit=" return checkForm()">
Type something: <br> <textarea id="info" name="info" > </textarea>
<input type="button" value="1" id="button1"> </input>
<input type="button" value="2" id="button2"> </input>
<input type="button" value="3" id="button3"> </input>
<input type="submit" id="submit" name="submit" class="btn" value="Submit" />
<input type="reset" id="reset" name="reset" class="btn" value="Clear" />
</form>
</body>
为我工作。 我看到的唯一问题是input: textarea
无效。 只需使用textarea
。
<head> <title> Example </title> <style type="text/css"> textarea{ resize: none; } input[type=button]{ //set the sizes for all of the input buttons width: 5em; height: 2em; font-size: 15px; font-weight: bold; } </style> </head> <body> <form id="mainForm" name="mainForm" method="get" action="" onsubmit="return checkForm()"> Type something: <br> <textarea id="info" name="info" > </textarea> <input type="button" value="1" id="button1"> <input type="button" value="2" id="button2"> <input type="button" value="3" id="button3"> <input type="submit" id="submit" name="submit" class="btn" value="Submit"> <input type="reset" id="reset" name="reset" class="btn" value="Clear"> </form> </body>
无需仅指定input
textarea
。 您甚至可以将inline css
用于textarea。
<style type="text/css">
textarea{
resize: none;
}
input[type=button]{
width: 5em; height: 2em;
font-size: 15px;
font-weight: bold;
}
</style>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.