|
工具版本兼容问题
如果style.css中,<style>标签中,style属性上有冲突的样式,那么谁的优先级更高?
示例
1
:
style标签与外部文件style.css样式重复
示例
2
:
style标签上的与style属性冲突
示例
3
:
!important
示例
1
:
style标签与外部文件style.css样式重复
顶
折
外部文件 style.css的内容是 .p1{ color:red; }
.span1{ color:blue; }
同时style标签中也有一个.p1 那么优先使用: 最后出现的一个
");
window.frames["iframe_show498"].document.write(decodeHtml($("textarea#stepcodeTextarea498").val()));
window.frames["iframe_show498"].document.close();
$(window.frames["iframe_show498"]).load(function(){
$("#iframe_show498").height($("#iframe_show498").contents().find("body").height()+showittryitheight);
});
$("#iframe_show498").height($("#iframe_show498").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/study/style.css" />
<style>
.p1{
color:green;
}
</style>
<p class="p1">p1 颜色是绿色,优先使用靠的最后出现的</p>
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/study/style.css" />
<style>
.p1{
color:green;
}
</style>
<p class="p1">p1 颜色是绿色,优先使用靠的最后出现的</p>
");
window.frames["iframe498"].document.write(decodeHtml(code498));
window.frames["iframe498"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe498"]).load(function(){
$("#iframe498").height($("#iframe498").contents().find("body").height()+showittryitheight);
});
$("#iframe498").height($("#iframe498").contents().find("body").height()+showittryitheight);
alreadyWriteCode498 = code498;
$("#rendering498").hide();
$("#rendered498").show();
}
var tRereshRetry2DemoPanel498 = setInterval(rereshRetry2DemoPanel498,1000);
var binded498 = false;
$("textarea#stepcodeTextarea498").keyup(function(){
if(!binded498){
$(window).bind('beforeunload',function(){
binded498 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code498 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code498!=newCode){
// window.frames["iframe498"].document.write("
");
// window.frames["iframe498"].document.write(decodeHtml($("textarea#stepcodeTextarea498").val()));
// window.frames["iframe498"].document.close();
// $(window.frames["iframe498"]).load(function(){
// $("#iframe498").height($("#iframe498").contents().find("body").height()+showittryitheight);
// });
// code498 = newCode;
// }
});
$(".tryButton498").click(function(){
$("#tryDiv498").show();
$("#stepcodeTextarea498").focus();
$("#stepcodeTextarea498").height(200);
$("#iframe498").height(0);
window.frames["iframe498"].document.write("
");
window.frames["iframe498"].document.write(decodeHtml($("textarea#stepcodeTextarea498").val()));
window.frames["iframe498"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe498"]).load(function(){
$("#iframe498").height($("#iframe498").contents().find("body").height()+showittryitheight);
});
$("#iframe498").height($("#iframe498").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor498.focus();
editor498.setSize(null, "250");
$("#rendering498").hide();
$("#rendered498").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor498 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea498"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor498.on("change",function(doc){
if(!binded498){
$(window).bind('beforeunload',function(){
binded498 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code498 = newCode;
$("textarea#stepcodeTextarea498").val(newCode);
if(alreadyWriteCode498!=code498){
lastModifedTime498 = new Date().getTime();
$("#rendering498").show();
$("#rendered498").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor498 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor498.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv498").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
示例
2
:
style标签上的与style属性冲突
顶
折
style标签上的与style属性冲突
优先使用style属性
");
window.frames["iframe_show499"].document.write(decodeHtml($("textarea#stepcodeTextarea499").val()));
window.frames["iframe_show499"].document.close();
$(window.frames["iframe_show499"]).load(function(){
$("#iframe_show499").height($("#iframe_show499").contents().find("body").height()+showittryitheight);
});
$("#iframe_show499").height($("#iframe_show499").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<style>
.p1{
color:green;
}
</style>
<p class="p1" style="color:red">p1 颜色是红色,优先使用style属性</p>
<style>
.p1{
color:green;
}
</style>
<p class="p1" style="color:red">p1 颜色是红色,优先使用style属性</p>
");
window.frames["iframe499"].document.write(decodeHtml(code499));
window.frames["iframe499"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe499"]).load(function(){
$("#iframe499").height($("#iframe499").contents().find("body").height()+showittryitheight);
});
$("#iframe499").height($("#iframe499").contents().find("body").height()+showittryitheight);
alreadyWriteCode499 = code499;
$("#rendering499").hide();
$("#rendered499").show();
}
var tRereshRetry2DemoPanel499 = setInterval(rereshRetry2DemoPanel499,1000);
var binded499 = false;
$("textarea#stepcodeTextarea499").keyup(function(){
if(!binded499){
$(window).bind('beforeunload',function(){
binded499 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code499 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code499!=newCode){
// window.frames["iframe499"].document.write("
");
// window.frames["iframe499"].document.write(decodeHtml($("textarea#stepcodeTextarea499").val()));
// window.frames["iframe499"].document.close();
// $(window.frames["iframe499"]).load(function(){
// $("#iframe499").height($("#iframe499").contents().find("body").height()+showittryitheight);
// });
// code499 = newCode;
// }
});
$(".tryButton499").click(function(){
$("#tryDiv499").show();
$("#stepcodeTextarea499").focus();
$("#stepcodeTextarea499").height(200);
$("#iframe499").height(0);
window.frames["iframe499"].document.write("
");
window.frames["iframe499"].document.write(decodeHtml($("textarea#stepcodeTextarea499").val()));
window.frames["iframe499"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe499"]).load(function(){
$("#iframe499").height($("#iframe499").contents().find("body").height()+showittryitheight);
});
$("#iframe499").height($("#iframe499").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor499.focus();
editor499.setSize(null, "250");
$("#rendering499").hide();
$("#rendered499").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor499 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea499"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor499.on("change",function(doc){
if(!binded499){
$(window).bind('beforeunload',function(){
binded499 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code499 = newCode;
$("textarea#stepcodeTextarea499").val(newCode);
if(alreadyWriteCode499!=code499){
lastModifedTime499 = new Date().getTime();
$("#rendering499").show();
$("#rendered499").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor499 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor499.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv499").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
如果样式上增加了!important,则优先级最高,甚至高于style属性
");
window.frames["iframe_show500"].document.write(decodeHtml($("textarea#stepcodeTextarea500").val()));
window.frames["iframe_show500"].document.close();
$(window.frames["iframe_show500"]).load(function(){
$("#iframe_show500").height($("#iframe_show500").contents().find("body").height()+showittryitheight);
});
$("#iframe_show500").height($("#iframe_show500").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<style>
.p1{
color:green !important;
}
</style>
<p class="p1" style="color:red">p1 颜色是绿色,优先使用!important样式</p>
<style>
.p1{
color:green !important;
}
</style>
<p class="p1" style="color:red">p1 颜色是绿色,优先使用!important样式</p>
");
window.frames["iframe500"].document.write(decodeHtml(code500));
window.frames["iframe500"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe500"]).load(function(){
$("#iframe500").height($("#iframe500").contents().find("body").height()+showittryitheight);
});
$("#iframe500").height($("#iframe500").contents().find("body").height()+showittryitheight);
alreadyWriteCode500 = code500;
$("#rendering500").hide();
$("#rendered500").show();
}
var tRereshRetry2DemoPanel500 = setInterval(rereshRetry2DemoPanel500,1000);
var binded500 = false;
$("textarea#stepcodeTextarea500").keyup(function(){
if(!binded500){
$(window).bind('beforeunload',function(){
binded500 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code500 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code500!=newCode){
// window.frames["iframe500"].document.write("
");
// window.frames["iframe500"].document.write(decodeHtml($("textarea#stepcodeTextarea500").val()));
// window.frames["iframe500"].document.close();
// $(window.frames["iframe500"]).load(function(){
// $("#iframe500").height($("#iframe500").contents().find("body").height()+showittryitheight);
// });
// code500 = newCode;
// }
});
$(".tryButton500").click(function(){
$("#tryDiv500").show();
$("#stepcodeTextarea500").focus();
$("#stepcodeTextarea500").height(200);
$("#iframe500").height(0);
window.frames["iframe500"].document.write("
");
window.frames["iframe500"].document.write(decodeHtml($("textarea#stepcodeTextarea500").val()));
window.frames["iframe500"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe500"]).load(function(){
$("#iframe500").height($("#iframe500").contents().find("body").height()+showittryitheight);
});
$("#iframe500").height($("#iframe500").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor500.focus();
editor500.setSize(null, "250");
$("#rendering500").hide();
$("#rendered500").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor500 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea500"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor500.on("change",function(doc){
if(!binded500){
$(window).bind('beforeunload',function(){
binded500 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code500 = newCode;
$("textarea#stepcodeTextarea500").val(newCode);
if(alreadyWriteCode500!=code500){
lastModifedTime500 = new Date().getTime();
$("#rendering500").show();
$("#rendered500").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor500 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor500.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv500").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|