【发布时间】:2017-04-24 22:29:22
【问题描述】:
好吧,这是我第一次遇到这种情况,我曾经在我的机器中使用 css 语言环境进行学习,这次它的行为很奇怪(或者我认为是)。
当我尝试设置页面样式时,样式不适用于按钮。我一直在寻找很多解决方法,比如使用 reset.css、拼写 <!DOCTYPE html> 对、在我的 css 声明中使用 type="text/css" 等等。
使用内联 css 可以正常工作,但是在 css 文件上编写相同的代码没有效果,奇怪的是其他 css 像表格或页面的其余部分都可以工作。
所以显然我不能覆盖用户代理样式表按钮样式。
这是我的 html 文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Botões</title>
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/custom.css" />
</head>
<body>
<div class="container">
<ul id="flex-container">
<li>
<button class="btn normal">Apertar</button>
</li>
<li>
<button class="full">Apertar</button>
</li>
<li>
<button class="block">Apertar</button>
</li>
<li>
<button class="outlined">Apertar</button>
</li>
<li>
<button class="clear">Apertar</button>
</li>
</ul>
</div>
</body>
</html>
还有我的 CSS 文件:
//PAGE:
html, body {
height: 100%;
box-sizing: border-box;
}
.container {
width: 95%;
margin: 0 auto;
}
ul#flex-container {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
}
ul li {
text-align: center;
padding: 30px 0;
width: 20%;
border: 1px dotted lightgray;
}
// ================================
button.btn {
font-size: 2.3em;
font-weight: bold;
text-transform: uppercase;
color: white;
cursor: pointer;
}
这是我运行此文件时的控制台输出
input[type="button" i], input[type="submit" i], input[type="reset" i], input[type="file" i]::-webkit-file-upload-button, button {
padding: 1px 6px;
}
user agent stylesheet
input[type="button" i], input[type="submit" i], input[type="reset" i], input[type="file" i]::-webkit-file-upload-button, button {
align-items: flex-start;
text-align: center;
cursor: default;
color: buttontext;
background-color: buttonface;
box-sizing: border-box;
padding: 2px 6px 3px;
border-width: 2px;
border-style: outset;
border-color: buttonface;
border-image: initial;
}
user agent stylesheet
input, textarea, select, button {
text-rendering: auto;
color: initial;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
margin: 0em 0em 0em 0em;
font: 13.3333px Arial;
}
user agent stylesheet
input, textarea, select, button, meter, progress {
-webkit-writing-mode: horizontal-tb;
}
user agent stylesheet
button {
-webkit-appearance: button;
}
我的文件结构如下:
|- index.html
|- css folder
|- custom.css
|- reset.css
这就是我的按钮的样子:
那么,如果我总是这样做并且工作正常,为什么我不能覆盖用户代理样式呢?这是新的 Google Chrome 更新吗?有没有办法让这个工作?
【问题讨论】: