Detailed example of using CSS to beautify HTML form controls (form beautification)

Detailed example of using CSS to beautify HTML form controls (form beautification)

1. Basic syntax structure of HTML submit and bottom button

1. HTML submit button

Setting type="submit" in the input tag can set this form control as a button.

Submit button code:


Copy code
The code is as follows:

<input name="" type="submit" value="Submit" />

Screenshot of submit button effect

HTML submit button effect screenshot

2. HTML bottom button

Setting type="bottom" in the input tag also sets this form control as a button.

Bottom button code:


Copy code
The code is as follows:

<input name="" type="button" value="Submit" />

Bottom button screenshot:

HTML botton button effect screenshot

2. The difference between HTML submit and bottom button

type=button is simply a button function

type=submit is to send the form

However, people working on WEB UI should note that using submit can improve page usability:

After using submit, the page supports keyboard enter key operation, but many WEB software designers may not notice the uniformity of submit.

After using the button, the page often does not support the enter key. Therefore, the enter key needs to be supported, and a submit must be set. By default, the enter key operates on the first submit of the page.


Copy code
The code is as follows:

<input type="submit" name="b1" value="Submit" onClick="bt_submit_onclick()">

After executing onClick, go to action. Can be submitted automatically without onClick. So onclick is not necessary here.


Copy code
The code is as follows:

<input type="button" name="b1" value="Submit" onClick="bt_submit_onclick()">

After executing onClick, the jump file is controlled in the js file. onClick is required for submit.

for example:

1. onclick="form1.action='a.jsp';form1.submit();" This implements the submit function.

2. Button code


Copy code
The code is as follows:

<form name="form1" method="post" action="<a href="http://www.css.com">http://www.css.com</a>">
<input type="button" name="Button" value="Button" onClick="submit()">
</form>

Button screenshot

3. Button HTML code


Copy code
The code is as follows:

<input type="button" name="Button" value="Button"
onClick="javascript:windows.location.href="your url"">

3. HTML submit and bottom button beautify CSS p layout

First, we prepare the button image for button beautification, and add a class style to the input submit or bottom button control, set the button background to the beautified image, and set the border to zero, width and height.

1. Beautify the HTML bottom button

1) Picture material

You can save the image as

Beautify picture button material

2) Corresponding complete HTML source code:


Copy code
The code is as follows:

<!DOCTYPE html>
<html>
<head>
<title>button beautification online demonstration-www.css.com</title>
<style>
html{width:100%;height:100%;}
body{background:#fff;font-size:18px;font-family:"Arial","Tahoma","Microsoft YaHei","YaHei";
line-height:18px;padding:0px;margin:0px;text-align:center}
div{padding:18px}
img{border:0px;vertical-align:middle;padding:0;margin:0}
input,button{font-family:"Arial","Tahoma","微软雅黑","雅黑";border:0;
vertical-align:middle;margin:8px;line-height:18px;font-size:18px}
.btn{width:140px;height:36px;line-height:18px;font-size:18px;
background:url("bg26.jpg")no-repeatlefttop;color:#FFF;padding-bottom:4px}
</style>
</head>
<body>
<p>
<formid="form1"name="form1"method=""action="<a href="http://www.css.com/"target="_blank">http://www.css.com/"target="_blank</a>">
<div>
<inputtype="button"class="btn"value="button"onmouseover="this.style.backgroundPosition='left-36px'"
onmouseout="this.style.backgroundPosition='lefttop'"/>
</div>
</form>
</p>
</body>
</html>


3) Screenshot of bottom effect

Screenshot of bottom beautification effect

2. Beautify the HTML submit button

1) Picture material

You can save the image as

Button picture material right click save as use

2) Corresponding complete HTML source code:


Copy code
The code is as follows:

<!DOCTYPE html>
<html>
<head>
<title>Submit button beautification online demo-www.css.com</title>
<!-- <a href="http://www.css.com">www.css.com</a> -->
<style>
html { width:100%; height:100%; }
body { background:#fff; font-size:18px; font-family:"Arial", "Tahoma", "微软雅黑", "雅黑";
line-height:18px; padding:0; margin:0; text-align:center; }
div { padding:18px }
img { border:0px; vertical-align:middle; padding:0px; margin:0px; }
input, button { font-family:"Arial", "Tahoma", "微软雅黑", "雅黑"; border:0;
vertical-align:middle; margin:8px; line-height:18px; font-size:18px }
.btns { width:143px; height:40px; background:url("bg11.jpg") no-repeat left top; color:#FFF; }
</style>
</head>
<body>
<p>
<form id="form1" name="form1" method="" action="<a href="http://www.css.com/">http://www.css.com/</a>" target="_blank">
<div>
<input type="submit" class="btns" onmouseover="this.style.backgroundPosition='left -40px'"
onmouseout="this.style.backgroundPosition='left top'" value="Submit" />
</div>
</form>
</p>
</body>
</html>

3) Screenshot of the submit button effect

Screenshot of the beautified HTML submit

<<:  MySQL multi-instance deployment and installation guide under Linux

>>:  Not all pop-ups are rogue. Tips on designing website pop-ups

Recommend

mysql add, delete, modify and query basic statements

grammar Here is the generic SQL syntax for INSERT...

Pure CSS to achieve cool neon light effect (with demo)

I have recently been following the CSS Animation ...

What are the benefits of semantic HTML structure?

one: 1. Semantic tags are just HTML, there is no ...

Method of building redis cluster based on docker

Download the redis image docker pull yyyyttttwwww...

How to control the startup order of docker compose services

summary Docker-compose can easily combine multipl...

Detailed explanation of MySQL/Java server support for emoji and problem solving

This article describes the support and problem so...

How to handle spaces in CSS

1. Space rules Whitespace within HTML code is usu...

A quick solution to the problem of PC and mobile adaptation

When making a web page, we usually need to consid...

Use dockercompose to build springboot-mysql-nginx application

In the previous article, we used Docker to build ...

Example of implementing text wrapping in html (mixed text and images in html)

1. Text around the image If we use the normal one...

After reading the introduction of CSS box model, you will not be confused

The property names often heard in web design: con...

Analysis of the principle of using PDO to prevent SQL injection

Preface This article uses pdo's preprocessing...

CSS code to achieve background gradient and automatic full screen

CSS issues about background gradient and automati...

How to install Docker on Windows 10 Home Edition

I recently used Docker to upgrade a project. I ha...