Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] 第132天 有哪些方式可以对一个DOM设置它的CSS样式? #1113

Open
haizhilin2013 opened this issue Aug 25, 2019 · 5 comments
Labels
css css

Comments

@haizhilin2013
Copy link
Collaborator

第132天 有哪些方式可以对一个DOM设置它的CSS样式?

@haizhilin2013 haizhilin2013 added the css css label Aug 25, 2019
@qhdxwdm
Copy link

qhdxwdm commented Aug 25, 2019

1.可以使用行内样式
2.可以使用style标签
3.可以使用link引入css文件
4.可以使用js动态修改

@Konata9
Copy link

Konata9 commented Aug 26, 2019

  1. 行内样式: <div style="text-align:center;">233</div>
  2. 内连样式:
    <head>
    ...
    <style>
    	div{
    		text-align: center;
    	}
    </style>
    ...
    </head>
    <body>
    ...
    </body>
  3. 外链样式:
    <head>
    ...
    <link href="..." rel="...">
    ...
    </head>

@EragonBubble
Copy link

外链,内联,行内,js脚本修改

@LinStan
Copy link

LinStan commented Aug 26, 2019

外链css样式文件中对对应节点绑定样式。
内联样式,在<style> 中写样式。
行内样式,在对应dom节点中写样式。
基于JS的innerHTML直接更改对应的样式。

let dom = document.getElementById('a');
dom.innerHTML="<div id='a' style='border:solid 1px red;width:300px;height:300px'>1</div>"

@ShuiXinSuoYu
Copy link

你们都说完了,我只有说666了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css css
Projects
None yet
Development

No branches or pull requests

6 participants