2015-11-07 96 views
0

我試圖把我的CSS代碼放在與我的HTML代碼相同的文件中,但它不能正確顯示(我不想只將我的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> 

這裏是它的外觀,當我將其鏈接 enter image description here

一個PIC這裏是一個事先知情同意當我嘗試將CS​​S放入HTLM文件時它的外觀如何變化 enter image description here

+0

注意,CSS僅定義['/ * ... * /'徵求意見(https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)。 '// ...'不被它支持。 –

+0

謝謝,是它! –

回答

1

無需指定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> 
+0

請看看我上傳的圖片 –

+0

@bobdylan現在更新,它會按預期工作。刪除/ /設置所有輸入按鈕的大小(因爲/ /不是一個CSS評論) – bakki

+0

謝謝你是對的! –

1

適合我。我看到的唯一問題是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>

相關問題