javascript
  • html
  • css
  • 2011-11-25 106 views 0 likes 
    0

    我正在使用JavaScript的HTML表單和它的作品,但兩個按鈕:取消並提交都在單獨的行(一個在另一個之上)。我怎樣才能讓它們水平對齊?如何把在同一水平對齊兩個按鈕?

    這裏是我的代碼:

    var new_comment_form = "<form id='add_comment' method='post'><textarea name='problem_comment' cols=60 rows=6 id='problem_comment'>" + problem_comment_text + "</textarea><input type='hidden' id='problem_id' name='problem_id' value='" + problem_id + "' /><input type='hidden' id='problem_comment_id' value='" + problem_comment_id + "' /><input type='submit' class='button' value='Edit Message' /><input type='button' class='button' id='cancel_comment' data-problem_id='" + problem_id + "' value='Cancel' /></form>"; 
    

    順便說一下,它看起來非常凌亂:)人們怎樣通常做這樣的事情,使得它更乾淨?

    謝謝!

    回答

    4

    http://jsfiddle.net/G2qsp/1/

    據我所知,他們是在同一行:P

    使它清潔劑(至少,像我這樣做)是隻把它的正常方式在每行末尾加上+的新行。

    又名:

    var new_comment_form = 
    "<form id='add_comment' method='post'>"+ 
        "<textarea name='problem_comment' cols=60 rows=6 id='problem_comment'>"+ 
         problem_comment_text + 
        "</textarea>"+ 
        "<input type='hidden' id='problem_id' name='problem_id' value='" + problem_id + "' />"+ 
        "<input type='hidden' id='problem_comment_id' value='" + problem_comment_id + "' />"+ 
        "<input type='submit' class='button' value='Edit Message' />"+ 
        "<input type='button' class='button' id='cancel_comment' data-problem_id='" + problem_id + "' value='Cancel' />"+ 
    "</form>"; 
    

    編輯: 如果您仍然遇到了一些調整問題,這大約是你想要與彩車 http://jsfiddle.net/G2qsp/2/

    做到現在,在逃離什麼有人攻擊我使用明確:既...

    0

    可以解決使用兩種方式, 1)使用表格有兩列,一個包含第一個按鈕,另一個包含第二個按鈕這個問題。 2)您也可以使用邊距風格,它的值是負的。

    +1

    表只顯示錶格數據。 –

    相關問題