html中一个div的id是“1:222”的话,怎么利用id给它定义css啊?

2019-03-25 13:36|来源: 网路


<style>
#1:2{
height:100px;
width:100px;
border:solid 1px red;
}
</style>



<div id="1:2">
</div>

我这样写实不管用的。
id中含有冒号这个事实我没法改变,而且只能用id来标示css请问哪位高手会。
必须满足的条件: id中有冒号   css中只能用#id来表示

相关问答

更多
  • 尽管允许将class或id设置为以HTML5中的数字开头,但在CSS中不允许,请参阅规范: HTML5:3.2.5.1 id属性 ......身份证可以采用什么形式没有其他限制; 特别是,ID可以只包含数字, 以数字开头,以下划线开头,仅包含标点符号等。 CSS:4.1.3个性和案例 ......他们不能以数字 ,两个连字符或连字符后跟数字开头。 标识符也可以包含转义字符和任何ISO 10646字符作为数字代码... 即
    是有效的HTML,但您无法在CSS中使用#1 {...}进行定 ...
  • 是的,是的,你可以。 #y.x { /* will select element of id="y" that also has class="x" */ } 同理: .x#y { /* will select elements of class="x" that also have an id="y" */ } 顺便说一句,这在一些用例中可能是有用的(其中类用于表示某种形式的事件或交互),但是在大多数情况下,它不一定是有用的,因为id在文档中是唯一的。 但是,如果您正在使用类进行用户交互,那么知道 ...
  • 有“直接孩子”选择器: #blah > div {margin:5px;} 但它不受IE6的支持 ,但遗憾的是仍然是许多观众的考虑因素。 最好将一个类添加到想要设置样式的框中:
    .... 并指定: #blah div.box {margin:5px;} There is the > "immediate child" selector: #blah > div {margin:5px;} but it's not ...
  • 这是HTML的有效版本: CSS Tutorial 1

    We are creating this pag ...

  • 首先,您不应该使用ID来选择那种项目。 更好地使用ID来识别您网站的区域。 但是,你可以在这里找到一个有效的代码: http : //jsfiddle.net/cjTN7/24/ #home, #about, #news { background-size: cover; } #home { height: 100px; width: 100px; } #about { height: 200px; width: 200px; } #news { height: ...
  • 在这里,你应该使用CSS的相邻选择器。 #menu img:hover + ul { background:red; } “+”(加号)CSS选择器是什么意思? 为了感谢你的善良,这里有一个适合你的jsfiddle。 https://jsfiddle.net/g4frLaak/2/ 哦,并修复你的HTML代码。 删除刚刚创建的图像的结束标记。 它不存在。
  • 目标元素的最佳方法是使用id或类,但您可以使用:nth-child #main > div { background-color:coral; width: 40%; float: left; } #main > div:nth-child(2) { background-color: lightblue; width: 60%; float: right; }
    Red DIV
    ...
  • 你的CSS: #content { width: 500px; width: 80%; //Why multiple declaration? height:1000; //Forgot unit i.e px or % margin: 0 auto 0 auto; background-color:#999 //Missed semicolon overflow:hidden; background-size:1980px 1080px; //Con ...
  • $(document).ready(function(){ if (typeof (jsondata[0]) == 'undefined') { $('#unassignedDevices').hide(); } }); $(document).ready(function(){ if (typeof (jsondata[0]) == 'undefined') { $('#unassignedDevices').hide(); } });