我想要一个带有图像的按钮。我正在使用这个:
<input type="submit" name="submit" src="images/stack.png" />
但它没有显示图片。我想要整个按钮都是图片。
我想要一个带有图像的按钮。我正在使用这个:
<input type="submit" name="submit" src="images/stack.png" />
但它没有显示图片。我想要整个按钮都是图片。
应该是这样的
<input type="image" id="myimage" src="[...]" />
所以改用 "image" 而不是 "submit"。它仍然会在单击时提交一个按钮。
如果您的图像比显示的按钮大;比如说图像尺寸为 200x200 像素;请将以下代码添加到您的样式表中:
#myimage {
height: 200px;
width: 200px;
}
或者直接在按钮标签中:<input type="image" id="myimage" style="height:200px;width:200px;" src="[...]" />
注意,像这样调整图像的大小可能不会产生理想的效果;例如,如果您的图像比您想要显示的图像小得多,则将看到单个像素;另一方面,如果它大得多,您将浪费用户宝贵的带宽。因此,通过将图片本身调整为实际大小而非使用样式表进行缩放更可取!
您可以使用CSS样式或使用图像输入来设计按钮。另外,您还可以使用支持内联内容的button
元素。
<button type="submit"><img src="/path/to/image" alt="Submit"></button>
<input type="submit" name="submit" style="background: url(images/stack.png); width:100px; height:25px;" />
应该是可以做到的,您可能想要添加border:none;来去除标准边框。
使用<button>
元素替代<input type=button />
<input type="button" value="text" name="text" onClick="{action}; return false" class="fwm_button">
以及CSS类
.fwm_button {
color: white;
font-weight: bold;
background-color: #6699cc;
border: 2px outset;
border-top-color: #aaccff;
border-left-color: #aaccff;
border-right-color: #003366;
border-bottom-color: #003366;
}
<input type="image" src="/library/graphics/cecb2.gif">
<input type= "image" id=" " onclick=" " src=" " />
它有效。
<a href="#">
<img src="p.png"></img>
</a>