应用一个类和一个属性选择器 [英] Apply a class AND an attribute selector

查看:50
本文介绍了应用一个类和一个属性选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要设置此元素的样式:

I want to style this element:

<input class="myslider" type="range" value="20">

正在运行:

input[class*="myslider"] {
    -webkit-appearance: none;
    width: 100px;
    background-color: black;
    height: 2px;
}

但这不起作用:

.myslider input[type=range] {
    -webkit-appearance: none;
    width: 100px;
    background-color: black;
    height: 2px;
}

为什么我不能应用类选择器属性选择器?

Why can't I apply a class selector and an attribute selector?

推荐答案

您要查找的选择器是

input.myslider[type=range]

您的当前代码查找子元素,但未定位适当的元素。

Your current code looks for children elements and doesn't target the appropriate element.

这篇关于应用一个类和一个属性选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆