1. click/hover 設(shè)置邊框時(shí),該元素內(nèi)的內(nèi)容發(fā)生下移
給元素本身添加該屬性(border),當(dāng)hover/click時(shí)只是改變了該屬性的值(顏色)而不是添加該屬性,這樣可以保證位置不變
div { border: 1px solid #fff; }
div:hover {border: 1px solid #ff5000;}
div.current {border: 1px solid #ff5000;}
$("div").click(function(){
if($(this).hasClass("current")){
$(this).removeClass("current");
}else{
$(this).addClass("current");
}
})
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。