Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input[type="button"], input[type="submit"], button CSS not behaving properly

Tags:

css

I'm trying to get this to work but there's still something not right.

I want to style the submit buttons with css to match the ones i already have.

<input type="submit" name="save_settings" value="Opslaan">

Style:

input[type="button"], input[type="submit"], button
{
   background: url("http://gasterijdebakker.nl/email/php/pages/images/layout/bg-btn-left.png") no-repeat scroll left top transparent;
   display: inline-block;
   line-height: 35px;
   padding:7px 0 15px 12px;
   margin:0;
   border:0;
   color: #FFFFFF;
   font-size: 15px;
   font-weight: bold;
   letter-spacing: -1px;
   text-shadow: 0 1px 1px #70A7E0;

}

jsFiddle

like image 839
Sander Kuipers Avatar asked Dec 29 '12 14:12

Sander Kuipers


People also ask

How do I fix submit button not working?

Why submit button is not working? Sometimes the problem is caused by old versions of the Javascript files, cached by your browser and can be fixed by clearing the browser cache. You can use the browser console of your browser for debugging.

How do I style a submit button in CSS?

The simplest way to do this is by using the WordPress CSS Editor. To open this, go to Appearance » Customize and select Additional CSS. Once you've opened the Additional CSS section, you can paste in your new CSS, click the Save & Publish button, and you're all set!

Is input type submit is the same as button type submit?

Both <button type="submit"> and <input type="submit"> display as buttons and cause the form data to be submitted to the server. The difference is that <button> can have content, whereas <input> cannot (it is a null element).

Can a button be of type submit?

The <button> tag with a type="submit" attribute creates a submit button.


2 Answers

You would be better off not using the background image and using css3 gradient instead. Something like:

input[type="button"], input[type="submit"], button
{

  background-color: #a3d4ff;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#a3d4ff), to(#88bcf2));
  background-image: -webkit-linear-gradient(top, #a3d4ff, #88bcf2);
  background-image:    -moz-linear-gradient(top, #a3d4ff, #88bcf2);
  background-image:      -o-linear-gradient(top, #a3d4ff, #88bcf2);
  background-image:         linear-gradient(to bottom, #a3d4ff, #88bcf2);
border-radius:3px;
    display: inline-block;
    line-height: 22px;
    padding:7px 12px;
    margin:0;
    border: 1px solid #88bcf2; 
    color: #FFFFFF;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: -1px;
    text-shadow: 0 1px 1px #70A7E0;
    cursor:pointer;
}​
like image 108
Mark Steggles Avatar answered Sep 30 '22 01:09

Mark Steggles


input elements can't be styled completely.

Instead, use a button element.

button elements are much easier to style than input elements. You can add inner HTML content (think em, strong or even img), and make use of :after and :before pseudo-element to achieve complex rendering while input only accept a text value attribute.

source:

Mozilla Developer Network

https://developer.mozilla.org/en-US/docs/HTML/Element/button

like image 39
hunterloftis Avatar answered Sep 30 '22 03:09

hunterloftis