Css input onclick style

CSS apply different style on onclick input type button

The following tutorial shows you how to use CSS to do «CSS apply different style on onclick input type button».

CSS Style

The CSS style to do «CSS apply different style on onclick input type button» is

.button_example < border:1px solid #a8c1d5; -webkit-border-radius:3px; -moz-border-radius:3px; border-radius:3px; font-size:12px; font-family:arial, helvetica, sans-serif; padding:10px 10px 10px 10px; text-decoration:none;!-- w w w . d e mo 2 s .c o m--> display:inline-block; text-shadow:-1px -1px 0 rgba(0,0,0,0.3); font-weight:bold; color:#FFFFFF; background-color:#CEDCE7; background-image:-webkit-gradient(linear, left top, left bottom, from(#CEDCE7), to(#596a72)); background-image:-webkit-linear-gradient(top, #CEDCE7, #596a72); background-image:-moz-linear-gradient(top, #CEDCE7, #596a72); background-image:-ms-linear-gradient(top, #CEDCE7, #596a72); background-image:-o-linear-gradient(top, #CEDCE7, #596a72); background-image:linear-gradient(to bottom, #CEDCE7, #596a72); filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#CEDCE7, endColorstr=#596a72); > .button_example:hover < border:1px solid #8aabc5; background-color:#acc4d6; background-image:-webkit-gradient(linear, left top, left bottom, from(#acc4d6), to(#434f55)); background-image:-webkit-linear-gradient(top, #acc4d6, #434f55); background-image:-moz-linear-gradient(top, #acc4d6, #434f55); background-image:-ms-linear-gradient(top, #acc4d6, #434f55); background-image:-o-linear-gradient(top, #acc4d6, #434f55); background-image:linear-gradient(to bottom, #acc4d6, #434f55); filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#acc4d6, endColorstr=#434f55); > .button_example:active < background:#000; >

HTML Body

body> input type="button" >"button_example" href="#" value="PREVIEW BUTTON">  

The following iframe shows the result. You can view the full source code and open it in another tab.

The following tutorial shows you how to use CSS to do «CSS apply different style on onclick input type button».

CSS Style

The CSS style to do «CSS apply different style on onclick input type button» is

HTML Body

body> input type="button" >"button_example" href="#" value="PREVIEW BUTTON">  

The following iframe shows the result. You can view the full source code and open it in another tab.

!-- w w w . d e m o 2 s. c o m --> http://jsbin.com Released under the MIT license: http://jsbin.mit-license.org --> html>head> script src="https://code.jquery.com/jquery-1.11.3.js">  style type="text/css"> style> .button_example< border:1px solid #a8c1d5; -webkit-border-radius: 3px; -moz-border-radius: 3px;border-radius: 3px;font-size:12px;font-family:arial, helvetica, sans-serif; padding: 10px 10px 10px 10px; text-decoration:none; display:inline-block;text-shadow: -1px -1px 0 rgba(0,0,0,0.3);font-weight:bold; color: #FFFFFF; background-color: #CEDCE7; background-image: -webkit-gradient(linear, left top, left bottom, from(#CEDCE7), to(#596a72)); background-image: -webkit-linear-gradient(top, #CEDCE7, #596a72); background-image: -moz-linear-gradient(top, #CEDCE7, #596a72); background-image: -ms-linear-gradient(top, #CEDCE7, #596a72); background-image: -o-linear-gradient(top, #CEDCE7, #596a72); background-image: linear-gradient(to bottom, #CEDCE7, #596a72);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#CEDCE7, endColorstr=#596a72); > .button_example:hover< border:1px solid #8aabc5; background-color: #acc4d6; background-image: -webkit-gradient(linear, left top, left bottom, from(#acc4d6), to(#434f55)); background-image: -webkit-linear-gradient(top, #acc4d6, #434f55); background-image: -moz-linear-gradient(top, #acc4d6, #434f55); background-image: -ms-linear-gradient(top, #acc4d6, #434f55); background-image: -o-linear-gradient(top, #acc4d6, #434f55); background-image: linear-gradient(to bottom, #acc4d6, #434f55);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#acc4d6, endColorstr=#434f55); > .button_example:active< background:#000; >  body> input type="button" >"button_example" href="#" value="PREVIEW BUTTON">    

  • CSS How are these websites full-screened in the browser with a learn more button at the bottom (moves you into automatically down the page)
  • CSS add confirmation dialog to a submit button in html5 form
  • CSS add two lines (one conditional) inside an html button
  • CSS apply different style on onclick input type button
  • CSS better format this div with buttons in it
  • CSS better format this div with buttons in it (Demo 2)
  • CSS change the background color of a button when clicked

demo2s.com | Email: | Demo Source and Support. All rights reserved.

Источник

How to Add an Onclick Effect with HTML and CSS

The most common way of creating a click event with CSS is using the checkbox hack. This method has broad browser support. You need to add a for attribute to the element and an id attribute to the element.

Example of adding an onclick event by using the checkbox hack:

html> html> head> style> label < display: block; background: #dbdbd9; width: 80px; height: 80px; > #box:checked + label < background: #fffc47; color: #666666; > style> head> body> form action="/form/submit" method="post"> input type="checkbox" id="box" /> label for="box">Click here label> form> body> html>

Result

In the example above, we applied the same value both to the id attribute of the tag and for attribute of the tag. The label onclick is restyled with the :checked pseudo-class.

Example of adding an onclick event for resizing the image:

html> html> head> style> #btnControl < display: none; > #btnControl:checked + label > img < width: 150px; height: 170px; > style> head> body> input type="checkbox" id="btnControl" /> label class="btn" for="btnControl"> img src="https://images.unsplash.com/photo-1565520651265-1148c3b277f4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" id="btnLeft" /> label> body> html>

Since a element can be associated only with one form control, you cannot just place a button inside the tag. But you can add some CSS to change the appearance and behavior of the button.

Example of adding an onclick effect on the tag:

html> html> head> style> #btnControl < display: none; > .btn < width: 80px; height: 30px; background: #ffffff; border-radius: 7px; padding: 1px 3px; box-shadow: 1px 1px 1px #000000; display: block; text-align: center; background-image: linear-gradient(to bottom, #e8e8e8, #a1a1a1); font-family: arial; font-size: 14px; line-height: 30px; > .btn:hover < background-image: linear-gradient(to bottom, #97e8ae, #3be36b); > .btn:active < margin-left: 1px 1px 0; box-shadow: -1px -1px 1px #000; outline: 1px solid #000000; -moz-outline-radius: 7px; background-image: linear-gradient(to top, #97e8ae, #3be36b); > #btnControl:checked + label < width: 70px; height: 74px; line-height: 74px; > style> head> body> input type="checkbox" id="btnControl" /> label class="btn" for="btnControl">Click here label> body> html>

Источник

The button is playing a very important role in a web application. Such as a filled form, sign in, sign up, etc. Every place where the action required from users needed a Button. In Html, you can use the button with 2 ways- tag and tag. In this tutorial, we will learn about HTML Input Button and see its examples.

HTML Input Button onClick Link, Disabled, Image and CSS

Syntax

It’s easy to use, just write tag and type=”button”. Here is a simple HTML Input Type Button syntax.

Example | How to use

See below, for example, HTML Input Button text. It’s using the same tag as an earlier tutorial – Input text box, Radio button, Checkbox.

Output: See below simple button example screenshot.

HTML Input Button Example output

Event | HTML Input Button onClick

When the user wants to take action that time onClick methods work. It will either hit the server or any javascript. In this HTML Input Button onClick Example we will look at how to perform JavaScript function.

   

HTML button onclick Event

function myFunction()

Output: See below GIF image how it looks.

HTML Input Button onClick example output

Value | Get

In the HTML input type button, the value attribute will show to the user. Whatever you will write on value=” Click…etc”, the same content shows to the user. See the example and output for the same.

html input type butto example

Q: How to the HTML input button disabled?

Answer: Use a disabled attribute in tag. See below line of code to how to write code of input button disabling.

After its user unable to click the button, another option is doing enabling and disabling buttons at runtime. Like the below code. By this, you can set a timeout session in the password reset button. A true means disabled and false means enabled.

Image | How to set

Some time is required to show the image in button. But how you can create an HTML input button image?

For that use input type as an image (type=”image”), and give source path off will with file (src=”path+name”). Src (source) is an attribute that gets the image for the button. See below the line of the code examp le.

Size | HTML input button Width and Height

Using Internal or external CSS you can set HTML input button width and Height. Changing the size of the button is easy to see below the code of the internal CSS input button example to change the size of it.

Input type Button CSS | Style |Color

By using CSS in the input type button you can change the style and color of it. Let’s see the one by one example, how to do it.

Input button Color

A using an Inline CSS to change button color.

html input button color

HTML input button style

Let’s do some style in the input type button with CSS. For this example, we will use Internal CSS. Where change the text color, size, background, border, etc.

   input[type=button], input[type=submit], input[type=reset] 

HTML input button style

Output: How to look like a button, see below.

HTML input button style

Answer: You can make tag with tag to do button as Link like this. See the below code line.

Do comment if you have any doubts and suggestions for this tutorial.

Note: The HTML Input Button Examples are tested on Safari browser (Version 12.0.2).
OS: macOS 10.14 Mojave
Code: HTML 5 Version

Источник

Читайте также:  Pdf to byte python
Оцените статью