国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁 web前端 js教程 js CSS操作方法集合_javascript技巧

js CSS操作方法集合_javascript技巧

May 16, 2016 pm 06:59 PM
css js 操作

//獲取元素的真實(shí)的,最終的CSS樣式屬性值的函數(shù)
function getStyle(elem,name){
if(elem.style[name]){
return elem.style[name];
}else if(elem.currentStyle){
return elem.currentStyle[name];
}else if(document.defaultView && document.defaultView.getComputedStyle){
name = name.replace(/([A-Z])/g,"-$1");
name = name.toLowerCase();

var s = document.defaultView.getComputedStyle(elem,"");
return s && s.getPropertyValue(name);
}else{
return null;
}
}
//兩個(gè)確定元素相對于整個(gè)文檔的X和Y位置的輔助位置
function pageX(elem){
return elem.offsetParent?
elem.offsetLeft+pageX(elem.offsetParent):
elem.offsetLeft;
}

function pageY(elem){
return elem.offsetParent?
elem.offsetTop+pageY(elem.offsetParent):
elem.offsetTop;
}
//確定元素相對于父親的位置的兩個(gè)函數(shù)
function parentX(elem){
return elem.parentNode == elem.offsetParent?
elem.offsetLeft:
pageX(elem)-pageX(elem.parentNode);
}

function parentY(elem){
return elem.parentNode==elem.offsetParent?
elem.offsetTop:
pageY(elem)-pageY(elem.parentNode);
}
//確定元素相對于它的CSS容器的位置
function posX(elem){
return parseInt(getStyle(elem,"left"));
}
function posY(elem){
return parseInt(getStyle(elem,"top"));
}
//設(shè)置元素x和y位置(與當(dāng)前位置無關(guān))的函數(shù)
function setX(elem,pos){
elem.style.left = pos+"px";
}
function setY(elem,pos){
elem.style.top = pos+"px";
}
//調(diào)整元素相對于當(dāng)前位置的距離的函數(shù)
function addX(elem,pos){
setX(posX(elem)+pos);
}
function addY(elem,pos){
setY(posY(elem)+pos);
}

//獲取元素當(dāng)前的高度和寬度
function getHeight(elem){
return parseInt(getStyle(elem,'height'));
}
function getWidth(elem){
return parseInt(getStyle(elem,'width'));
}
//即是元素隱藏,也能分別獲取它潛在的完整高度和寬度的兩個(gè)函數(shù)
function fullHeight(elem){
if(getStyle(elem,'display')!='none'){
return elem.offsetHeight||getHeight(elem);
}
var old = resetCSS(elem,{
display:'',
visibility:'hidden',
position:'absolute'
});
var h = elem.clientHeight||getHeight(elem);
restoreCSS(elem,old);
return h;
}

function fullWidth(elem){
if(getStyle(elem,'display')!='none'){
return elem.offsetWidth || getWidth(elem);
}
var old = resetCSS(elem,{
display:'',
visibility:'hidden',
position:'absolute'
});
var w = elem.clientWidth || getWidth(elem);
restoreCSS(elem,old);
return w;
}

function resetCSS(elem,prop){
var old = [];
for(var i in prop){
old[i] = elem.style[i];
elem.style[i] = prop[i];
}
return old;
}
function restoreCSS(elem,prop){
for(var i in prop){
elem.style[i] = prop[i];
}
}
//使用CSS的display屬性來切換元素可見性的一組函數(shù)
function hide(elem){
var curDisplay = getStyle(elem,'display');
if(curDisplay != 'none'){
elem.$oldDisplay= curDisplay;
}
elem.style.display = 'none';
}
function show(elem){
elem.style.display = elem.$oldDisplay ||'';

}
//設(shè)置元素的透明度
function setOpacity(elem,level){
if(elem.filters){
elem.style.filters = 'alpha(opacity='+level+')';
}else{
elem.style.opacity = level/100;
}
}

本網(wǎng)站聲明
本文內(nèi)容由網(wǎng)友自願(yuàn)投稿,版權(quán)歸原作者所有。本站不承擔(dān)相應(yīng)的法律責(zé)任。如發(fā)現(xiàn)涉嫌抄襲或侵權(quán)的內(nèi)容,請聯(lián)絡(luò)admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣圖片

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅(qū)動(dòng)的應(yīng)用程序,用於創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強(qiáng)大的PHP整合開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

什麼是AutoPrefixer,它如何工作? 什麼是AutoPrefixer,它如何工作? Jul 02, 2025 am 01:15 AM

Autoprefixer是一個(gè)根據(jù)目標(biāo)瀏覽器範(fàn)圍自動(dòng)為CSS屬性添加廠商前綴的工具。 1.它解決了手動(dòng)維護(hù)前綴易出錯(cuò)的問題;2.通過PostCSS插件形式工作,解析CSS、分析需加前綴的屬性、依配置生成代碼;3.使用步驟包括安裝插件、設(shè)置browserslist、在構(gòu)建流程中啟用;4.注意事項(xiàng)有不手動(dòng)加前綴、保持配置更新、非所有屬性都加前綴、建議配合預(yù)處理器使用。

您如何使用CSS對SVG進(jìn)行動(dòng)畫動(dòng)畫? 您如何使用CSS對SVG進(jìn)行動(dòng)畫動(dòng)畫? Jun 30, 2025 am 02:06 AM

AnimatingSVGwithCSSispossibleusingkeyframesforbasicanimationsandtransitionsforinteractiveeffects.1.Use@keyframestodefineanimationstagesforpropertieslikescale,opacity,andcolor.2.ApplytheanimationtoSVGelementssuchas,,orviaCSSclasses.3.Forhoverorstate-b

什麼是圓錐級函數(shù)? 什麼是圓錐級函數(shù)? Jul 01, 2025 am 01:16 AM

theconic-Gradient()functionIncsscreatesCircularGradientsThatRotateColorStopSaroundAcentralPoint.1.IsidealForPieCharts,ProgressIndicators,colordichers,colorwheels和decorativeBackgrounds.2.itworksbysbysbysbydefindefingincolordefingincolorstopsatspecificains off.

CSS教程專注於移動(dòng)優(yōu)先設(shè)計(jì) CSS教程專注於移動(dòng)優(yōu)先設(shè)計(jì) Jul 02, 2025 am 12:52 AM

Mobile-firstCSSdesignrequiressettingtheviewportmetatag,usingrelativeunits,stylingfromsmallscreensup,optimizingtypographyandtouchtargets.First,addtocontrolscaling.Second,use%,em,orreminsteadofpixelsforflexiblelayouts.Third,writebasestylesformobile,the

CSS教程,用於創(chuàng)建加載旋轉(zhuǎn)器和動(dòng)畫 CSS教程,用於創(chuàng)建加載旋轉(zhuǎn)器和動(dòng)畫 Jul 07, 2025 am 12:07 AM

創(chuàng)建CSS加載旋轉(zhuǎn)器的方法有三種:1.使用邊框的基本旋轉(zhuǎn)器,通過HTML和CSS實(shí)現(xiàn)簡單動(dòng)畫;2.使用多個(gè)點(diǎn)的自定義旋轉(zhuǎn)器,通過不同延遲時(shí)間實(shí)現(xiàn)跳動(dòng)效果;3.在按鈕中添加旋轉(zhuǎn)器,通過JavaScript切換類來顯示加載狀態(tài)。每種方法都強(qiáng)調(diào)了設(shè)計(jì)細(xì)節(jié)如顏色、大小、可訪問性和性能優(yōu)化的重要性,以提升用戶體驗(yàn)。

歐洲虛擬幣交易平臺排行榜2025年最新榜單TOP10盤點(diǎn)(最近更新) 歐洲虛擬幣交易平臺排行榜2025年最新榜單TOP10盤點(diǎn)(最近更新) Jul 11, 2025 pm 08:57 PM

2025年歐洲十大虛擬貨幣交易平臺包括Binance、OKX、Coinbase等,依據(jù)合規(guī)性、安全性、費(fèi)用、資產(chǎn)種類和用戶體驗(yàn)評選。 1. Binance:全球交易量最大,費(fèi)率低,已獲多國牌照;2. OKX:產(chǎn)品全面,技術(shù)強(qiáng),已在法國註冊;3. Coinbase:合規(guī)安全,適合初學(xué)者,在多國獲許可;4. Gate.io:歷史悠久,安全性高,在歐洲多國註冊;5. Bitstamp:成立早,合規(guī)性強(qiáng),受盧森堡監(jiān)管;6. eToro:支持社交交易,多元化投資,受CySEC監(jiān)管;7. Bitpanda:界

CSS中使用@supports的功能檢測是什麼? CSS中使用@supports的功能檢測是什麼? Jul 02, 2025 am 01:14 AM

prainuredetectionIncsssusissuse@supportScheckSifabRowsEsuppecifortSupecifortEfeatureBeforeApplyingReplyingStyles.1.itusesconditionalcsssssbasssbasedonproperty-valueperty-valuepairs,suessas@supports@supports@supports@supports(display:grid)

將CSS和JavaScript與HTML5結(jié)構(gòu)有效整合。 將CSS和JavaScript與HTML5結(jié)構(gòu)有效整合。 Jul 12, 2025 am 03:01 AM

HTML5、CSS和JavaScript應(yīng)通過語義化標(biāo)籤、合理加載順序與解耦設(shè)計(jì)高效結(jié)合。 1.使用HTML5語義化標(biāo)籤如、提升結(jié)構(gòu)清晰度與可維護(hù)性,利於SEO和無障礙訪問;2.CSS應(yīng)置於中,使用外部文件並按模塊拆分,避免內(nèi)聯(lián)樣式與延遲加載問題;3.JavaScript推薦放在前引入,使用defer或async異步加載以避免阻塞渲染;4.減少三者間強(qiáng)依賴,通過data-*屬性驅(qū)動(dòng)行為、類名控制狀態(tài),統(tǒng)一命名規(guī)範(fàn)提升協(xié)作效率。這些方法能有效優(yōu)化頁面性能與團(tuán)隊(duì)協(xié)作。

See all articles