工作一年多,发现博客大家都不怎么写了,本着分享的原则,这一年大大小小也积累了一些知识,希望大家少踩坑,当然,踩坑并不一定是坏事,那是一种成长。
前端制作考虑情况:
前端制作遇到的一些小问题:
IE7下设置overflow、z-index属性时,需同时对元素设置position:relative;
谷歌不兼容cursor:pointer问题解决方法:
input[type="file"]::-webkit-file-upload-button{cursor:pointer;}
.reply_pop {
margin:0px auto;
position: absolute;
}
脚本
$(function () {
$(window).resize(function () {
// 设置弹框div位置
setPosition($("#reply_pop"));
}).resize();
});
function setPosition(pop){
pop.css("top",($(window).height()-pop.height())/2+'px');
pop.css("left",($(window).width()-pop.width())/2+'px');
}
function setIFrameHeight(iframe) {
var ifm_content = document.getElementById("conFrame");
ifm_content.height = "500px";//默认设置为500px
var heightContent = "500px";
var subContent = document.frames ? document.frames["conFrame"].document : ifm_content.contentDocument;
if (iframe == "content") {//如果传入Ifame Id 等于content 重新给iframe赋值高度
heightContent = Math.max(subContent.body.scrollHeight, subContent.documentElement.scrollHeight);
ifm_content.height = heightContent;
}
}
实例说明:
Html中有一个Iframe 用法如下:
<iframe id="conFrame" src="a.html" frameborder="0" scrolling="no"
width="100%"height="500px"onload="setIFrameHeight('content');">iframe>
注:自动改变高度只是在初始化的时候将iframe高度设置成内容高度,当页面动态添加标签元素时,iframe高度不可自动增长,导致页面内容被遮住,目前比较好的方法是将iframe高度设置为窗口大小,显示滚动条。
$(function(){
$("#content").load(function(){
var client_h=document.documentElement.clientHeight || document.body.clientHeight;
var iframe_h=client_h-$(".f_wrap").height();
$(this).height(iframe_h);
});
});
$(window).resize(function() {
var client_h=document.documentElement.clientHeight || document.body.clientHeight;
var iframe_h=client_h-$(".f_wrap").height()-4;
$("#content").height(iframe_h);
});
input:disabled{
background-color: #f5f5f5;
}
input[disabled]{
background-color: #f5f5f5;
}
*html{background-image:url(about:blank);background-attachment:fixed;}
::-webkit-input-placeholder {
/* WebKit browsers */
color: #ccc;
}
:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
color: #ccc;
}
::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: #ccc;
}
:-ms-input-placeholder {
/* Internet Explorer 10+ */
color: #ccc;
}
input[type="button"], input[type="submit"], input[type="reset"] {
-webkit-appearance: none;
}
textarea {
-webkit-appearance: none;
}
overflow:hidden; text-overflow:ellipsis;display:-webkit-box; -webkit-box-orient:vertical;
-webkit-line-clamp:2; /*限制显示两行*/
iframe{display:block;}
<label class="defaultChex">
<input type="checkbox" name="default1">
折扣店
label>
好了,这次就发这么多,还有一些js和jQuery笔记,后续再发,有问题随时讨论哈。
事始:只要你还在尝试,就不算失败。