通过CSS捕捉页面中的所有单选框

今天需要对一堆已经完成的页面进行表单部分CSS精简。 在精简过程中发现在firefox中单选框和复选框与label的位置始终无法同时垂直对齐。

类似的页面很多,手工对radio和checkbox分配不同的class进行设置显然很不明知。隐约记得CSS3中支持一种可以根据设置属性值来寻找元素的方法,于是就查了下资料。

这句可以捕捉到所有type=”radio”的元素。

input[type^="radio"] {margin-bottom:-3px}

类似的方法还有:

a[href$=".pdf"] {border:1px solid red} 捕捉所有pdf后缀的链接。

Tags: 06月 2nd, 2008 Posted in CSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress | Blue Weed by Blog Oh! Blog | Entries (RSS) and Comments (RSS).