前端开发

CSS3可以根据分辨率来识别设备类型,然后写相应的CSS代码:

内容



/* Custom, iPhone Retina */

@media only screen and (min-width : 320px) { }


/* Extra Small Devices, Phones */

@media only screen and (min-width : 480px) { }


/* Small Devices, Tablets */

@media only screen and (min-width : 768px) { }


/* Medium Devices, Desktops */

@media only screen and (min-width : 992px) { }


/* Large Devices, Wide Screens */

@media only screen and (min-width : 1200px) { }

标签

css

css文本超出div就隐藏并且显示省略号

内容

style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"


overflow:hidden; //超出的文本隐藏



text-overflow:ellipsis; //溢出用省略号显示



white-space:nowrap; //溢出不换行






标签

css

用js对HTML转义和html反转义

内容

//HTML转义

function HTMLEncode(html) {

var temp = document.createElement("div");

(temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);

var output = temp.innerHTML;

temp = null;

return output;

}



var tagText = "<p><b>123&456</b></p>";

console.log(HTMLEncode(tagText));//&lt;p&gt;&lt;b&gt;123&amp;456&lt;/b&gt;&lt;/p&gt;



//HTML反转义

function HTMLDecode(text) {

var temp = document.createElement("div");

temp.innerHTML = text;

var output = temp.innerText || temp.textContent;

temp = null;

return output;

}

var tagText = "<p><b>123&456</b></p>";

var encodeText = HTMLEncode(tagText);

console.log(encodeText);//&lt;p&gt;&lt;b&gt;123&amp;456&lt;/b&gt;&lt;/p&gt;

console.log(HTMLDecode(encodeText)); //<p><b>123&456</b></p>



标签

js

|{ value.name }