如何在提交按钮中设置文本颜色?

时间:2012-09-18 05:54:26

标签: html css button submit-button

我尝试更改提交按钮类型中文本的颜色,但我不知道为什么我无法更改它。

.button {
  width: 105px;
  height: 20px;
  background-image: url('tiny.gif');
  line-height: 20px;
  padding-bottom: 2px;
  vertical-align: middle;
  font-family: "Lucida Grande", Geneva, Verdana, Arial, Helvetica, sans-serif;
  font-size: 13px;
  <!--font-weight: bold;
  -->text-transform: none;
  border: 1px solid transparent;
}

.button:hover {
  background-image: url('tiny_.gif');
}
<input type="submit" value="Fetch" class="button" />

当我尝试更改提交按钮的颜色时,我遇到了问题。

6 个答案:

答案 0 :(得分:47)

.button {
    color: green;
}

jsFiddle Live Demo

答案 1 :(得分:21)

你试试这个:

<input type="submit" style="font-face: 'Comic Sans MS'; font-size: larger; color: teal; background-color: #FFFFC0; border: 3pt ridge lightgrey" value=" Send Me! ">

答案 2 :(得分:5)

<button id="fwdbtn" style="color:red">Submit</button> 

答案 3 :(得分:3)

使用此CSS:

color: red;

就是这样。

答案 4 :(得分:-1)

// Set canvas size (how many 'pixels' are on the canvas)
// NOTE CSS determines how large the canvas is, this determines
// the size of the things you draw on it.
const width = 800;
const height = 600;
const canvasAspectRatio = width / height;

// Also define the gap we want at the edges:
const edgeMargin = 10;

// Set the number of 'pixels' in the canvas.
canvas.width = width;
canvas.height = height;

// Sets the canvas size based on the window height and width
function setCanvasElementSize () {
  const windowWidth = window.innerWidth;
  const windowHeight = window.innerHeight;

  // Work out the orientation of the device.
  const isPortrait = window.innerHeight > window.innerWidth;

  if (isPortrait) {
    // We want to constrain the canvas by its width
    canvas.style.width = windowWidth - (2 * edgeMargin);
    // The height depends on the width to ensure we don't stretch pixels
    // on the canvas.
    canvas.style.height = canvas.style.width / canvasAspectRatio;
  } else {
    // constrain by height
    canvas.style.height = windowHeight - (2 * edgeMargin);
    canvas.style.width = canvas.style.height * canvasAspectRatio;
  }
}

// Call the function once initially to size the canvas
setCanvasElementSize();

// Also add a resize listener so we can ensure the canvas is 
// adjusted when the screen rotates.

// BONUS: Only do this once per animation frame.
let rafRequest = null;
window.addEventListener('resize', function () {
  if (rafRequest) {
    clearAnimationFrame(animationFrameReference);
  }

  let rafRequest = requestAnimationFrame(function () {
    rafRequest = null;
    setCanvasElementSize();
  });
});

答案 5 :(得分:-2)

<input type = "button" style ="background-color:green"/>