|
工具版本兼容问题
<div>
<span>
这两种标签都是布局用的
这种标签本身没有任何显示效果
通常是用来结合css进行页面布局
示例
1
:
看不出任何效果
示例
2
:
div布局
示例
3
:
div和span的区别
");
window.frames["iframe_show352"].document.write(decodeHtml($("textarea#stepcodeTextarea352").val()));
window.frames["iframe_show352"].document.close();
$(window.frames["iframe_show352"]).load(function(){
$("#iframe_show352").height($("#iframe_show352").contents().find("body").height()+showittryitheight);
});
$("#iframe_show352").height($("#iframe_show352").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
这没有标签
<div> 这是一个div </div>
<span>这是一个span</span>
这没有标签
<div> 这是一个div </div>
<span>这是一个span</span>
");
window.frames["iframe352"].document.write(decodeHtml(code352));
window.frames["iframe352"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe352"]).load(function(){
$("#iframe352").height($("#iframe352").contents().find("body").height()+showittryitheight);
});
$("#iframe352").height($("#iframe352").contents().find("body").height()+showittryitheight);
alreadyWriteCode352 = code352;
$("#rendering352").hide();
$("#rendered352").show();
}
var tRereshRetry2DemoPanel352 = setInterval(rereshRetry2DemoPanel352,1000);
var binded352 = false;
$("textarea#stepcodeTextarea352").keyup(function(){
if(!binded352){
$(window).bind('beforeunload',function(){
binded352 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code352 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code352!=newCode){
// window.frames["iframe352"].document.write("
");
// window.frames["iframe352"].document.write(decodeHtml($("textarea#stepcodeTextarea352").val()));
// window.frames["iframe352"].document.close();
// $(window.frames["iframe352"]).load(function(){
// $("#iframe352").height($("#iframe352").contents().find("body").height()+showittryitheight);
// });
// code352 = newCode;
// }
});
$(".tryButton352").click(function(){
$("#tryDiv352").show();
$("#stepcodeTextarea352").focus();
$("#stepcodeTextarea352").height(200);
$("#iframe352").height(0);
window.frames["iframe352"].document.write("
");
window.frames["iframe352"].document.write(decodeHtml($("textarea#stepcodeTextarea352").val()));
window.frames["iframe352"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe352"]).load(function(){
$("#iframe352").height($("#iframe352").contents().find("body").height()+showittryitheight);
});
$("#iframe352").height($("#iframe352").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor352.focus();
editor352.setSize(null, "250");
$("#rendering352").hide();
$("#rendered352").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 editor352 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea352"), {
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);
}
}
});
editor352.on("change",function(doc){
if(!binded352){
$(window).bind('beforeunload',function(){
binded352 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code352 = newCode;
$("textarea#stepcodeTextarea352").val(newCode);
if(alreadyWriteCode352!=code352){
lastModifedTime352 = new Date().getTime();
$("#rendering352").show();
$("#rendered352").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor352 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor352.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv352").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
一个简单的div布局的例子
注: 这里使用了 style外边距样式,margin-left:50px 指的是左边距50个像素
需要对两个图片进行左边距控制
如果不使用div,则需要对每一个图像设置边距
使用了div后,先把两个图像都放在一个div里
只需要设置div的边距,就可以达到两个图片都移动的效果
");
window.frames["iframe_show354"].document.write(decodeHtml($("textarea#stepcodeTextarea354").val()));
window.frames["iframe_show354"].document.close();
$(window.frames["iframe_show354"]).load(function(){
$("#iframe_show354").height($("#iframe_show354").contents().find("body").height()+showittryitheight);
});
$("#iframe_show354").height($("#iframe_show354").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<img style="margin-left:50px" src="http://127.0.0.1/example.gif"/>
<br/>
<img style="margin-left:50px" src="http://127.0.0.1/example.gif"/>
<div style="margin-left:100px" >
<img src="http://127.0.0.1/example.gif"/>
<br/>
<img src="http://127.0.0.1/example.gif"/>
</div>
<img style="margin-left:50px" src="http://127.0.0.1/example.gif"/>
<br/>
<img style="margin-left:50px" src="http://127.0.0.1/example.gif"/>
<div style="margin-left:100px" >
<img src="http://127.0.0.1/example.gif"/>
<br/>
<img src="http://127.0.0.1/example.gif"/>
</div>
");
window.frames["iframe354"].document.write(decodeHtml(code354));
window.frames["iframe354"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe354"]).load(function(){
$("#iframe354").height($("#iframe354").contents().find("body").height()+showittryitheight);
});
$("#iframe354").height($("#iframe354").contents().find("body").height()+showittryitheight);
alreadyWriteCode354 = code354;
$("#rendering354").hide();
$("#rendered354").show();
}
var tRereshRetry2DemoPanel354 = setInterval(rereshRetry2DemoPanel354,1000);
var binded354 = false;
$("textarea#stepcodeTextarea354").keyup(function(){
if(!binded354){
$(window).bind('beforeunload',function(){
binded354 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code354 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code354!=newCode){
// window.frames["iframe354"].document.write("
");
// window.frames["iframe354"].document.write(decodeHtml($("textarea#stepcodeTextarea354").val()));
// window.frames["iframe354"].document.close();
// $(window.frames["iframe354"]).load(function(){
// $("#iframe354").height($("#iframe354").contents().find("body").height()+showittryitheight);
// });
// code354 = newCode;
// }
});
$(".tryButton354").click(function(){
$("#tryDiv354").show();
$("#stepcodeTextarea354").focus();
$("#stepcodeTextarea354").height(200);
$("#iframe354").height(0);
window.frames["iframe354"].document.write("
");
window.frames["iframe354"].document.write(decodeHtml($("textarea#stepcodeTextarea354").val()));
window.frames["iframe354"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe354"]).load(function(){
$("#iframe354").height($("#iframe354").contents().find("body").height()+showittryitheight);
});
$("#iframe354").height($("#iframe354").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor354.focus();
editor354.setSize(null, "250");
$("#rendering354").hide();
$("#rendered354").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 editor354 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea354"), {
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);
}
}
});
editor354.on("change",function(doc){
if(!binded354){
$(window).bind('beforeunload',function(){
binded354 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code354 = newCode;
$("textarea#stepcodeTextarea354").val(newCode);
if(alreadyWriteCode354!=code354){
lastModifedTime354 = new Date().getTime();
$("#rendering354").show();
$("#rendered354").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor354 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor354.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv354").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
div是块元素,即自动换行
常见的块元素还有h1,table,p
span是内联元素,即不会换行
常见的内联元素还有img,a,b,strong
");
window.frames["iframe_show353"].document.write(decodeHtml($("textarea#stepcodeTextarea353").val()));
window.frames["iframe_show353"].document.close();
$(window.frames["iframe_show353"]).load(function(){
$("#iframe_show353").height($("#iframe_show353").contents().find("body").height()+showittryitheight);
});
$("#iframe_show353").height($("#iframe_show353").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<div>
第一个div
</div>
<div>
第二个div
</div>
<span>
第一个span
</span>
<span>
第二个span
</span>
<div>
第一个div
</div>
<div>
第二个div
</div>
<span>
第一个span
</span>
<span>
第二个span
</span>
");
window.frames["iframe353"].document.write(decodeHtml(code353));
window.frames["iframe353"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe353"]).load(function(){
$("#iframe353").height($("#iframe353").contents().find("body").height()+showittryitheight);
});
$("#iframe353").height($("#iframe353").contents().find("body").height()+showittryitheight);
alreadyWriteCode353 = code353;
$("#rendering353").hide();
$("#rendered353").show();
}
var tRereshRetry2DemoPanel353 = setInterval(rereshRetry2DemoPanel353,1000);
var binded353 = false;
$("textarea#stepcodeTextarea353").keyup(function(){
if(!binded353){
$(window).bind('beforeunload',function(){
binded353 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code353 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code353!=newCode){
// window.frames["iframe353"].document.write("
");
// window.frames["iframe353"].document.write(decodeHtml($("textarea#stepcodeTextarea353").val()));
// window.frames["iframe353"].document.close();
// $(window.frames["iframe353"]).load(function(){
// $("#iframe353").height($("#iframe353").contents().find("body").height()+showittryitheight);
// });
// code353 = newCode;
// }
});
$(".tryButton353").click(function(){
$("#tryDiv353").show();
$("#stepcodeTextarea353").focus();
$("#stepcodeTextarea353").height(200);
$("#iframe353").height(0);
window.frames["iframe353"].document.write("
");
window.frames["iframe353"].document.write(decodeHtml($("textarea#stepcodeTextarea353").val()));
window.frames["iframe353"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe353"]).load(function(){
$("#iframe353").height($("#iframe353").contents().find("body").height()+showittryitheight);
});
$("#iframe353").height($("#iframe353").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor353.focus();
editor353.setSize(null, "250");
$("#rendering353").hide();
$("#rendered353").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 editor353 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea353"), {
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);
}
}
});
editor353.on("change",function(doc){
if(!binded353){
$(window).bind('beforeunload',function(){
binded353 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code353 = newCode;
$("textarea#stepcodeTextarea353").val(newCode);
if(alreadyWriteCode353!=code353){
lastModifedTime353 = new Date().getTime();
$("#rendering353").show();
$("#rendered353").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor353 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor353.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv353").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|