English 中文(简体)
如何选择无“类型”的“投放”
原标题:How to select <input> that has no "type" with CSS
  • 时间:2011-11-22 06:00:11
  •  标签:
  • css
  • html

我在此有3个<代码><input>。

Name: <input><br>
Age: <input type="number"><br>
Site: <input type="url">

我可以选择与这些特别安全局的底线二:

input[type="number"]{
    color: gray;
}
input[type="url"]{
    color: blue;
}

But I don t know how to select the first one that has no type.
I tried:

input{
    color: red;
}

但它也将改变另外两个。

input[type=""]{
    color: red;
}

This is still not working.
Any idea?

最佳回答

选任人<代码>[类型=”>将寻找一种包含特性的投稿件:<代码> 类型,该词被定为空文。 使用:

input:not([type]) { }

见jsFiddle.

问题回答

另一种做法是使用CSSSpeciality,对所有投入要素采用一般风格,然后对包含e>类内容的投入采用更具体的方式:>

您对交叉浏览器兼容性的最佳依据或许只是界定了你想要的东西,然后又重新界定了每种类型的投入。 即:

input {
    color: red;
}
input[type="button"],
input[type="submit"],
...
input[type="input"] {
    color: red;
}

也许,你可以向你们希望提供的投入添加一个奖状或等级。 例如:

Name: <input id="name-input">

Then in your css:

#name-input
{
   color: red
}

IE6

input[type="text"]:first-child

页: 1

#form input[type="text"]:first-child




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签