云切图

HTML

HTML标签复习,帮你快速掌握html标签,助推学生快速完成网页作业

首页 > 前端笔记 > HTML

html怎么给按钮换颜色?网页按钮button标签使用介绍

作者:admin 发布时间:2022-09-06 点击数:
<p>本篇文章主要的介绍了关于html button按钮标签的一些应用,主要是介绍了button标签如何换颜色等,本章中都是基础的知识,希望大家好好掌握,多多练习,现在让我们一起来看这篇文章吧</p><p>首先我们先介绍下按钮的标签:</p><p><button>标签定义一个按钮。</p><p>在 button元素内部,您可以放置内容,比如文本或图像。这是该元素与使用input元素创建的按钮之间的不同之处。</p><p><button>控件与<input type="button">相比,提供了更为强大的功能和更丰富的内容。<button>与</button>标签之间的所有内容都是按钮的内容,其中包括任何可接受的正文内容,比如文本或多媒体内容。例如,我们可以在按钮中包括一个图像和相关的文本,用它们在按钮中创建一个吸引人的标记图像。</p><p>唯一禁止使用的元素是图像映射,因为它对鼠标和键盘敏感的动作会干扰表单按钮的行为。</p><p>请始终为按钮规定type属性。Internet Explorer的默认类型是"button",而其他浏览器中(包括W3C规范)的默认值是"submit"。</p><p>注释:如果在HTML表单中使用button元素,不同的浏览器会提交不同的按钮值。请使用input元素在HTML表单中创建按钮。</p><p>介绍了这么多,让我们对html button标签的认识加深了点。</p><p>现在让我们看看HTML如何给按钮换颜色:</p><pre class="brush:html;toolbar:false"><!DOCTYPE&nbsp;html>&nbsp; <html>&nbsp; <head>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="Content-Type"&nbsp;content="text/html;&nbsp;charset=utf-8"&nbsp;/>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<title>学生网页作业:button标签实例</title>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<style></style>&nbsp; </head>&nbsp; <body>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<button>学生网页作业</button>&nbsp; </body>&nbsp; </html></pre><p>这是一个最简单的按钮,如图:</p><p><img style="max-width:100%!important;height:auto!important;" src="/uploads/allimg/20221019/1-22101Z9302cW.jpg" title="html怎么给按钮换颜色?网页按钮button标签使用介绍(图1)" alt="01.jpg"/></p><p>这个简单的按钮相信大家应该都会吧,现在我们来看看加些样式颜色的代码实例:</p><pre class="brush:html;toolbar:false"><!DOCTYPE&nbsp;html>&nbsp; <html>&nbsp; <head>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="Content-Type"&nbsp;content="text/html;&nbsp;charset=utf-8"&nbsp;/>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<title>学生网页作业:button标签实例</title>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<style> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.btn{background-color:&nbsp;#7ED321;&nbsp;width:&nbsp;100px;&nbsp;height:&nbsp;36px;&nbsp;color:&nbsp;#fff;} &nbsp;&nbsp;&nbsp;&nbsp;</style>&nbsp; </head>&nbsp; <body>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<button&nbsp;class="btn">学生网页作业</button>&nbsp; </body>&nbsp; </html></pre><p>这是加了些简单的属性之类的,让它变了样式,看看现在变成什么样了:</p><p><img style="max-width:100%!important;height:auto!important;" src="/uploads/allimg/20221019/1-22101Z93134405.jpg" title="html怎么给按钮换颜色?网页按钮button标签使用介绍(图2)" alt="02.jpg"/></p><p>这样的样式是不是比原来的样式要好很多啊,还可以加很多样式,大家可以自己上手敲敲代码的。</p><p>现在来看下button标签的属性介绍</p><p>是为了让大家在敲代码的时候忘了自己需要的属性了</p><p>上就是这篇文章的全部内容了,button标签的换颜色相信大家应该都会了吧,这些都是最基础的应用,等学到了高级的,那么就感觉现在学的这些都不算什么了。加油一起努力~~</p><p><br/></p>

关注我们共同进步

  • 扣扣交流群

  • 微信公众号

  • 私技术顾问

嘿,我来帮您!