在接下来的文章中,我们将学习关于使用HTML5的图像按钮。
task we are making the image to act as a button, When the user clicks the button, the
form is sent to the server. Let’s look into it.
什么是图像按钮
图像按钮是通过将a1f02c36ba31691bcfe87b2722de723b标签放置在bb9345e55eb71822850ff156dfde57c8标签内部创建的,它创建了一个可点击的HTML按钮,并嵌入了图像。
a1f02c36ba31691bcfe87b2722de723b 标签
By using the a1f02c36ba31691bcfe87b2722de723b tag we can include an image on a HTML page. Images are not actually embedded in the webpages; instead, they are connected to them via predetermined paths. The tag consists of two required attributes namely src and alt.
Syntax
Following is the syntax for a1f02c36ba31691bcfe87b2722de723b tag
<img src=”..” alt=”..”>
<button> tag
A clickable button is defined by the <button> tag. You can insert text (as well as tags like <i>, <b>, <strong>, <br> and <img> etc.) inside a <button> element. With a button made with the <input> element, that is not feasible!
Let’s look into the examples for understanding of image button with HTML5.
Example 1
在下面的示例中,我们正在创建一个简单的图像按钮。
<!DOCTYPE html> <html> <body> <p>Click On The Image</p> <button onclick="JavaScript:alert('DONT HUNT ANIMALS')"> <img width="60" height="40" src="https://www.tutorialspoint.com/coffeescript/images/coffeescript.jpg" alt="animal"> <br>LOVE ANIMALS</button> </body> </html>
When the script gets executed, it will generate an output displaying the image button with text on it along with a prompt on the webpage.
When the user clicks the image button, the event gets triggered and displays an alert “Don’t hunt animals”.
Example 2
在下面的示例中,我们使用<input type=” image”>创建了一个图像按钮。
<!DOCTYPE html>
<html>
<body style="text-align: center">
<h2>creating an image Button with HTML5?</h2>
<form>
USERNAME:
<input type="name" /><br><br>
PASSWORD:
<input type="password" /><br><br>
<input type="image" src=
"https://www.tutorialspoint.com/images/logo.png"
height="80px" width="110px"
alt="submit" />
</form>
</body>
</html>
When the script gets executed, it will generate an output displaying the input field for username and password along with an image button on the webpage. When the user clicks the image button, the form gets submitted to the server.
Example 3
在下面的示例中,我们使用占位符和一个带有<input type=”image”的图像按钮。
<!DOCTYPE html>
<html>
<head>
<style>
input[type='image'] {
width: 80px;
}
</style>
</head>
<body style="text-align: center">
<p>SIGN IN </p>
<div>
<input type="email"
placeholder="Enter your email Address" />
<br><br>
</div>
<input type="image" id="image" alt="Login"
src="https://www.tutorialspoint.com/images/logo.png">
</body>
</html>
On running the above script, the output window will pop up, displaying the sign in provided with a placeholder for entering email along with an image button on the webpage.
Example 4
In the following we are creating a image button but inserting <img> tag inside the <button> tag.
<button type = "submit" name = "learn" value = "myimage"> <p>Tutorials for all</p> <img src="https://www.tutorialspoint.com/latest/inter-process-communication.png%20" /> </button>
运行上述脚本后,它将在网页上生成一个包含文本的图像按钮。
以上就是使用HTML5的图像按钮的详细内容,更多请关注双恒网络其它相关文章!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
8. 精力有限,不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别
9.本站默认解压密码为:www.sudo1.com
本站提供的一切软件、教程和内容信息仅限用于学习和研究目的。
不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。
如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。
我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!
云资源网 » 使用HTML5的图像按钮
常见问题FAQ
- 免费下载或者VIP会员专享资源能否直接商用?
- 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
- 提示下载完但解压或打开不了?
- 你们有qq群吗怎么加入?