[英]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.