Rumah >hujung hadapan web >tutorial js >js melaksanakan kemahiran perkongsian kod separa penyesuaian skrin_javascript

js melaksanakan kemahiran perkongsian kod separa penyesuaian skrin_javascript

WBOY
WBOYasal
2016-05-16 16:16:581257semak imbas

Sesetengah rakan meninggalkan mesej yang mengatakan bahawa mereka memerlukan kod js untuk melaksanakan penyesuaian skrin separa. Saya telah menyusunnya secara ringkas di sini dan mengeluarkannya untuk semua orang.

Salin kod Kod adalah seperti berikut:





Dokumen Tanpa Tajuk

*{
jidar:0;
pelapik:0;
gaya senarai:tiada;
}
div{
margin:0 auto;
ketinggian:10000px;
lebar min:880px;
lebar maks:1100px;
latar belakang:#060;
jelas:keduanya;
}
ul{}
li{
float:left;
paparan:sebaris;
lebar:198px;
ketinggian:198px;
sempadan:1px pepejal #ccc;
jidar:10px;
}





                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              



var winWidth;
window.onload=function(){
jika (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
if(winWidth<=1100)
document.getElementById("main").style.width="880px";
else if(winWidth>=1100)
document.getElementById("main").style.width="1100px";
}
window.onresize=function(){
jika (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
if(winWidth<=1100)
document.getElementById("main").style.width="880px";
else if(winWidth>=1100)
document.getElementById("main").style.width="1100px";
}






Cuba dan lihat jika ia berfungsi dengan baik. Saya harap anda semua menyukainya.
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn