Html 是 <div style="width: ;height: ;background: "> CSS 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40690282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:02:40  来源:igfitidea点击:

Is <div style="width: ;height: ;background: "> CSS?

htmlcss

提问by Noob Web Dev

Is <div style="width: ;height: ;background: ">CSS?

<div style="width: ;height: ;background: ">CSS 吗?

回答by Bhavin Shah

For example :

例如 :

<div style="height:100px; width:100px; background:#000000"></div>

here.

这里。

you give css to div of heightand widthhaving 100pxand backgroundas black.

您将 css 赋予高度宽度100px背景black 的div

PS :try to avoid inline-cssyou can make external CSS and import in your html file.

PS:尽量避免inline-css您可以制作外部 CSS 并导入您的 html 文件。

you can refer herefor CSS

你可以参考这里的 CSS

hope this helps.

希望这可以帮助。

回答by Sharavnan Kv

Yes, it is called Inline CSS, Here you styling the divusing some height, width, and background.

是的,它被称为内联 CSS,在这里您可以div使用一些高度、宽度和背景来设置样式。

Here the example:

这里的例子:

<div style="width:50px;height:50px;background color:red">

You can achieve same using Internalor External CSS

您可以使用内部外部 CSS实现相同的目标

2.Internal CSS:

2.内部CSS:

  <head>
    <style>
    div {
    height:50px;
    width:50px;
    background-color:red;
    foreground-color:white;
    }
    </style>
  </head>
  <body>
    <div></div>
  </body>

3.External CSS:

3.外部CSS:

<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div></div>
</body>

style.css /external css file/

style.css /外部 css 文件/

 div {
        height:50px;
        width:50px;
        background-color:red;
    }

回答by Legend Yeong

1)Yes it is, when there is style then it is styling your code(css).2) is belong to html it is like a container that keep your css.

1)是的,当有样式时,它会为您的代码(css)设置样式。2)属于 html,它就像一个保存您的 css 的容器。