开发者

How to set the size of the box of a form?

开发者 https://www.devze.com 2023-01-30 03:08 出处:网络
I am using this form and its appearing as it should in dreamweaver but when I use it in on the website its big again. the site is loaded via include as dynamic content (php).

I am using this form and its appearing as it should in dreamweaver but when I use it in on the website its big again. the site is loaded via include as dynamic content (php).

<form action="inde开发者_如何学JAVAx.php" method="get">
        <input type="hidden" name="content" value="home" />
        <label>Go to
          <input style height="20" width="40" type="numeric" name="page" />
        </label>
        <input type="submit" value="Go" />
      </form>

I appreciate any help!


Add style="width:Npx; height:Mpx;" where needed in favor of the deprecated width and height HTML attributes.

Example:

<form action="index.php" method="get">
    <input type="hidden" name="content" value="home" />
    <label>Go to
        <input style="height:20px; width:40px" type="numeric" name="page" />
    </label>
    <input type="submit" value="Go" />
</form>


Or, use the width property in CSS: <form style='width:##px'> The <form> element is displayed by default as block, therefore it strecthes all over the width of its parent


Although other the other answers here will probably work, inline style tags should ideally be avoided.

Really, you should set up a CSS stylesheet, give the input element a class and set the styles you want for this class in the stylesheet. The advantage of doing it this way is that if you have a more than form element like this in your website you can just add the class name and it will be appear in the same way (this is especially important if you change how things look).

Using CSS has a learning curve, but it will pay off many times in the long run.

0

精彩评论

暂无评论...
验证码 换一张
取 消