【发布时间】:2011-11-14 11:56:53
【问题描述】:
您好,我不想要提交按钮的图像,所以我使用了默认提交按钮,但我想编辑它的宽度和高度。我该怎么做?
<input type="submit" id="search" value="Search" />
谢谢!
詹姆斯
【问题讨论】:
您好,我不想要提交按钮的图像,所以我使用了默认提交按钮,但我想编辑它的宽度和高度。我该怎么做?
<input type="submit" id="search" value="Search" />
谢谢!
詹姆斯
【问题讨论】:
只需使用带有高度和宽度选项的样式属性
<input type="submit" id="search" value="Search" style="height:50px; width:50px" />
【讨论】:
使用 CSS,您可以使用 id (#) 选择器为特定按钮设置样式:
#search {
width: 20em; height: 2em;
}
或者如果您希望所有提交按钮都具有特定大小:
input[type=submit] {
width: 20em; height: 2em;
}
或者,如果您希望某些类别的按钮成为特定样式,您可以使用 CSS 类:
<input type="submit" id="search" value="Search" class="search" />
和
input.search {
width: 20em; height: 2em;
}
我使用 ems 作为度量单位,因为它们tend to scale better。
【讨论】:
border: none 才能看到这些更改。
<style media="screen" type="text/css">...embed here...</style> 括起来 - 哇!
使用以下方法更改高度:
input[type=submit] {
border: none; /*rewriting standard style, it is necessary to be able to change the size*/
height: 100px;
width: 200px
}
【讨论】:
<input type="button" value="submit" style="height: 100px; width: 100px; left: 250; top: 250;">
根据您的要求使用它。
【讨论】:
你可以用css改变高度和宽度:
#search {
height: 100px;
width: 400px;
}
值得指出的是,OSX 上的 safari 会忽略大多数输入按钮样式。
【讨论】:
{border: none;}
使用CSS。
在<head> 标记内(#search 表示“ID 为 search 的元素”)
<style type="text/css">
input#search
{
width: 20px;
height: 20px;
}
</style>
或内联,在您的<input> 标记中
<input type="submit" id="search" value="Search" style="width: 20px; height: 20px;" />
【讨论】:
border: none 才能看到这些更改。
使用 css height 和 width 属性。
为了在 Mac 上工作,您还需要将 button 的 border 设置为 none。
【讨论】:
这很简单!
首先,给你的按钮一个id,比如<input type="button" value="I am a button!" id="myButton" />
然后,对于高度和宽度,使用 CSS 代码:
.myButton {
width: 100px;
height: 100px;
}
你也可以这样做:
input[type="button"] {
width: 100px;
height: 100px;
}
但这会影响页面上的所有按钮。
工作示例 - JSfiddle
【讨论】:
只需添加 style="width:auto"
<input type="submit" id="search" value="Search" style="width:auto" />
这在 IE、Firefox 和 Chrome 中对我有用。
【讨论】: