【问题标题】:Why does my browser not show the css button in the html script? [closed]为什么我的浏览器没有在 html 脚本中显示 css 按钮? [关闭]
【发布时间】:2020-02-11 16:45:27
【问题描述】:
<!DOCTYPE html>
<html>
<head>
 <link href="Button1" rel:"stylesheet" type = "text/css">
</head>
</html>
 /* CSS Document */
 type = text/css>
 .button {
 background-color: #4CAF50; /* Green */
 border: none;
 color: white;
 padding: 15px 32px;
 text-align: center;
 text-decoration: none;
 display: inline-block;
 font-size: 16px;
}

为什么这不起作用。我已经构建了一个简单的 html 脚本并从 youtube 复制了一个 css 脚本,该脚本应该构建一个按钮(不能编写 css :-( )。我尝试使用不同的方式将 css 脚本包含在 html 编程中。但是如果我看本地主机我看不到任何按钮

【问题讨论】:

  • CSS 不负责在 HTML 中创建/构建任何内容。 CSS 仅用于风格化,如果 HTML 中没有类 button 的按钮(样式为 css .button{...}),则不存在按钮
  • 非常感谢 :-)

标签: html css button localhost


【解决方案1】:

因为您还没有将任何类 .button 的元素添加到您的 HTML 中。 CSS 不会创建元素,HTML 会。 CSS 提供样式。

查看sn-p。

.button {
  background-color: #4CAF50;
  /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
}
<!DOCTYPE html>
<html>

<head>
  <link href="Button1" rel: "stylesheet" type="text/css">
</head>

<body>
  <button type="button" class="button">Button</button>
  
  <div class="button">blala</div>
  
  <span class="button">roar</span>
</body>

</html>

【讨论】:

  • 非常感谢:/)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-07
  • 2021-12-23
  • 2017-07-04
  • 1970-01-01
  • 2023-04-06
  • 1970-01-01
相关资源
最近更新 更多