如何用js控制margin-bottom属性 js获取css属性,更改margin-top属性,给每个a标...

\u5982\u4f55\u7528JavaScript\u8bbe\u7f6eDiv\u7684margin\u53c2\u6570\uff1f

element.style.marginTop = '0px';
element.style.marginRight = '0px';
element.style.marginBottom = '0px';
element.style.marginLeft = '0px';

\u53ef\u4ee5\u53c2\u8003\u4e0b\u9762\u7684\u4ee3\u7801\uff1a

a{display:block;float:left}


asd
asd
asd
asd
asd


for(var i=1;i<6;i++){
document.getElementById('a'+i).style.marginTop = parseInt(document.getElementById('a'+i).style.marginTop)+5+'px';
}

JavaScript\u662f\u4e00\u79cd\u5c5e\u4e8e\u7f51\u7edc\u7684\u811a\u672c\u8bed\u8a00,\u5df2\u7ecf\u88ab\u5e7f\u6cdb\u7528\u4e8eWeb\u5e94\u7528\u5f00\u53d1,\u5e38\u7528\u6765\u4e3a\u7f51\u9875\u6dfb\u52a0\u5404\u5f0f\u5404\u6837\u7684\u52a8\u6001\u529f\u80fd,\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u6d41\u7545\u7f8e\u89c2\u7684\u6d4f\u89c8\u6548\u679c\u3002
\u901a\u5e38JavaScript\u811a\u672c\u662f\u901a\u8fc7\u5d4c\u5165\u5728HTML\u4e2d\u6765\u5b9e\u73b0\u81ea\u8eab\u7684\u529f\u80fd\u7684\u3002\u5b83\u6700\u521d\u7531Netscape\u7684Brendan Eich\u8bbe\u8ba1\u3002JavaScript\u662f\u7532\u9aa8\u6587\u516c\u53f8\u7684\u6ce8\u518c\u5546\u6807\u3002Ecma\u56fd\u9645\u4ee5JavaScript\u4e3a\u57fa\u7840\u5236\u5b9a\u4e86ECMAScript\u6807\u51c6\u3002

\u6269\u5c55\u8d44\u6599\uff1a
javaScript\u53c2\u8003\u51fd\u6570
anchor("name")\u7528\u6765\u628a\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3aHTML\u951a\u9762\u6807\u5fd7\u5185()
big() \u628a\u5b57\u7b26\u4e32\u4e2d\u7684\u6587\u672c\u53d8\u6210\u5927\u5b57\u4f53()
blink() \u628a\u5b57\u7b26\u4e32\u4e2d\u7684\u6587\u672c\u53d8\u6210\u95ea\u8000\u5b57\u4f53()
bold() \u628a\u5b57\u7b26\u4e32\u4e2d\u7684\u6587\u672c\u53d8\u6210\u4e4c\u5b57\u4f53()
fixed() \u628a\u5b57\u7b26\u4e32\u4e2d\u7684\u6587\u672c\u53d8\u6210\u6d41\u52a8\u95f4\u8ddd\u5b57\u4f53,\u4fbf\u7535\u62a5\u60c5\u52bf()
fontcolor(color)\u8bbe\u7f6e\u5b57\u7b26\u4e32\u4e2d\u6587\u672c\u7684\u8272\u5f69()
Fontsize(size) \u628a\u5b57\u7b26\u4e32\u4e2d\u7684\u6587\u672c\u53d8\u6210\u6307\u5b9a\u5927\u5c0f()
italics() \u628a\u5b57\u7b26\u4e32\u4e2d\u7684\u767d\u539f\u53d8\u6210\u659c\u5b57\u4f53()
Link(url)\u7528\u6765\u628a\u5b57\u7b26\u4e32\u8f6c\u6362-HTML\u94fe\u4ea4\u6807\u5fd7\u4e2d()
\u53c2\u8003\u8d44\u6599\u6765\u6e90\uff1a\u767e\u5ea6\u767e\u79d1-javascript

这个东西叫做局部样式,他的优先级别是最高的。用它就是为了临时设置一些样式,不建议大量使用。

CSS 属性它都可以使用
onmouseover="this.style.marginBottom='1px'"

this.style.marginBottom

  • js鑾峰彇css灞炴,鏇存敼margin-top灞炴,缁欐瘡涓猘鏍囩鐨刴argin-top灞炴鍦鍘...
    绛旓細<div style="border:1px solid #cccccc"> <a id="a1" href="#" class="float_r" style="margin-top:10px;">asd</a> <a id="a2" href="#" class="float_r" style="margin-top:20px;">asd</a> <a id="a3" href="#" class="float_r" style="margin-top:30px;">asd</...
  • js鐐瑰嚮ul涓煇涓猯i鏍囩,鏀瑰彉杩欎釜li鏍囩鐨勮儗鏅浘,褰撶偣鍑诲叾瀹僱i鏍囩鏃跺墠...
    绛旓細1銆佹柊寤轰竴涓猦tml鏂囦欢锛屽懡鍚嶄负test.html銆2銆佸湪test.html鏂囦欢鍐咃紝浣跨敤ul鍜宭i鏍囩鍒涘缓涓涓垪琛紝li鐨勫煎垎鍒负娴嬭瘯a锛屾祴璇昩銆3銆佸湪test.html鏂囦欢鍐咃紝璁剧疆绗竴涓猯i鏍囩鐨刬d涓簃ytest锛屼富瑕佺敤浜庝笅闈㈤氳繃璇d鑾峰緱li瀵硅薄銆4銆佸湪test.html鏂囦欢鍐咃紝浣跨敤button鏍囩鍒涘缓涓涓寜閽紝鎸夐挳鍚嶇О涓衡滄敼鍙榣i鐨勫尖濄5...
  • 姹備竴缁勪唬鐮!!!
    绛旓細.pop_3_right_1_1_a{width:87px; border-left:1px #C4809A solid; border-top:1px #B35B7D solid; height:20px; background-image:url(http://www.pcpop.com/pp/images/tu3-bg.gif); background-repeat:repeat-x; color:#CF4500; font-weight:bold; margin:0px; padding:7px 0px 3px 0px; ...
  • js濡備綍鑾峰彇琛ㄦ牸涓煇涓琛岀殑鍗曞厓鏍兼暟
    绛旓細document.getElementById('first').cells.length // 鑾峰彇id涓篺irst鐨勮鐨勫崟鍏冩牸鏁扮洰瀹炰緥婕旂ず濡備笅锛氬垱寤篐tml鍏冪礌 <div class="box"><span>瀹炰緥婕旂ず锛氳幏鍙栬〃鏍肩涓琛岀殑鍗曞厓鏍兼暟閲</span><br><div class="content"> <table> <tr id="first"><td>1</td><td>2</td><td>3</td></tr...
  • 鎴戝湪鍋氱Щ鍔ㄧ鏃堕亣瑙佺殑css闂
    绛旓細瀹炵幇鍘熺悊鏄:璁╁唴閮ㄤ袱涓猻pan瀹藉害鐩哥瓑,鍏朵腑涓涓缃畐idth:0%;overflow:hidden; 鐒跺悗鐢╦s鍔ㄦ鎺у埗width浠0% -- 100%銆 瀹炵幇鏂瑰紡2:(寮犻懌鏃鍙傜敤浜巆hrome,浣嗘槸鎴戞祴浜嗕笅,濂藉儚firefox涔熸槸鍙互鐨勩) 瀹炵幇鍘熺悊:background-image鏄鐩栧湪background-color涓婄殑,chrome鏈変釜绉佹湁灞炴 -webkit-background-clip:text; 鎰忎负鑳...
  • 鎵撳嵃JS鎬庝箞鐢鐨
    绛旓細//js<span id="2_nwp" style="width: auto; height: auto; float: none;"><a id="2_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=c072f1078117b9d&k=style&k0=style&kdi0=0&luki=7&n=10&...
  • 濡備綍鐢css js鍒朵綔璁$畻鍣?
    绛旓細/*鏄敤inset鍙互灏嗗閮ㄩ槾褰辨敼鎴愬唴閮ㄩ槾褰;鑻ヨ瀹炵幇鍐呭闃村奖鍚屾椂瀛樺湪锛屽皢鍏跺苟鍦ㄤ竴琛岀敤閫楀彿闅斿紑*/ .calBox{ width:460px; padding-bottom:10px;background:#FDFDFD; border-radius:5px; position:absolute; left:50%; top:50%; margin-left:-230px; margin-top:-225px; box-shadow:0px 0px 10...
  • 鍦HTML涓,濡備綍鎺у埗CSS浣夸袱涓厓绱犲眳涓潬鎷絾鏄張淇濇寔涓瀹氳窛绂?
    绛旓細500px;height:250px;margin:0 auto;} .a,.b{float:left;} .a{width:250px;height:250px;margin-right:50px;background:#f00} .b{width:200px;height:250px;background:#0f0} </style> <div class="div1"> <div class="a"></div> <div class="b"></div> </div> ...
  • 缃戦〉璁捐濡備綍璁剧疆缃戦〉閮ㄥ垎鍐呭涓嶉殢鐫婊氬姩鏉¤岀Щ鍔ㄧЩ鍔?
    绛旓細4銆佷娇鍏冪礌鍥哄畾鍦ㄨ窛娴忚鍣ㄧ獥鍙g殑搴曢儴b鍍忕礌鐨勪綅缃細top{ _position:absolute;_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));_margin-...
  • css濡備綍瀹炵幇缃戦〉鍐呯殑娴姩绐楀彛鐨勬渶灏忓寲鍜屽叧闂
    绛旓細<head> <title>JS+CSS瀹炵幇鍙渶灏忓寲/鍏抽棴鐨勫彸涓嬭娴姩绐楀彛</title> <style type="text/css"> msg_win{position:absolute;right:0px;display:none;overflow:hidden;z-index:99;border:1px solid #c00;background:#F9EFFC;width:240px;font-size:12px;margin:0px;} msg_win .icos{position:...
  • 扩展阅读:js修改css样式margin ... 138卫星专用接收机 ... mjs工法桩动画演示 ... ms测试 ... 智能灌溉控制系统 ... mjs桩机设备图片 ... 控制遥控器 ... smartgen发电机说明书 ... 手摇通坐便器使用视频 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网