如何使按钮保持相同的链接颜色?

时间:2014-12-28 03:56:39

标签: html css colors hyperlink

点击索引提交按钮的颜色" New Value"变化与变化保持灰色,这是访问过的链接的颜色,而 _form提交按钮保持相同的颜色白色。

我希望按钮保持白色,而所有其他链接应根据是否被访问来改变颜色。

你能帮帮我吗?

index.html.erb



  <div class="form-group">
    <%= link_to 'New Value', new_value_path, class: "btn btn-primary" %>
  </div>
&#13;
&#13;
&#13;

_form.html.erb

&#13;
&#13;
  <div class="form-group">
    <%= f.submit class: "btn btn-primary" %>
  </div>
&#13;
&#13;
&#13;

values.css.scss

&#13;
&#13;
// Place all the styles related to the Values controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.category {
  width: 130px
}

td {
  padding-top: .7em;
  padding-bottom: .7em;
  padding-left: .7em;
  padding-right: .7em;
}

.btn {
  background: #3498db;
  background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
  background-image: -moz-linear-gradient(top, #3498db, #2980b9);
  background-image: -ms-linear-gradient(top, #3498db, #2980b9);
  background-image: -o-linear-gradient(top, #3498db, #2980b9);
  background-image: linear-gradient(to bottom, #3498db, #2980b9);
  -webkit-border-radius: 28;
  -moz-border-radius: 28;
  border-radius: 28px;
  font-family: Arial;
  color: #ffffff;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
}

.btn:hover {
  background: #3cb0fd;
  background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
  background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
  background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
  background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
  background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
  text-decoration: none;
}

.btn:active{
  color:red;
}
&#13;
&#13;
&#13;

scaffolds.css.scss

&#13;
&#13;
body {
  background-color: #fff;
  color: #333;
  font-family: verdana, arial, helvetica, sans-serif;
  font-size: 13px;
  line-height: 18px;
}

p, ol, ul, td {
  font-family: verdana, arial, helvetica, sans-serif;
  font-size: 13px;
  line-height: 18px;
}

pre {
  background-color: #eee;
  padding: 10px;
  font-size: 11px;
}

a {
  color: #000;
  &:visited {
    color: #666;
  }
  &:hover {
    color: #fff;
    background-color: #000;
  }
}

div {
  &.field, &.actions {
    margin-bottom: 10px;
  }
}

#notice {
  color: green;
}

.field_with_errors {
  padding: 2px;
  background-color: red;
  display: table;
}

#error_explanation {
  width: 450px;
  border: 2px solid red;
  padding: 7px;
  padding-bottom: 0;
  margin-bottom: 20px;
  background-color: #f0f0f0;
  h2 {
    text-align: left;
    font-weight: bold;
    padding: 5px 5px 5px 15px;
    font-size: 12px;
    margin: -7px;
    margin-bottom: 0px;
    background-color: #c00;
    color: #fff;
  }
  ul li {
    font-size: 12px;
    list-style: square;
  }
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

在索引页面中,您使用的是link_to项,这将为您提供<a>的行为。 你给a的CSS作为

a {
  color: #000;
  &:visited {
    color: #666;
  }
  &:hover {
    color: #fff;
    background-color: #000;
  }
}

所以颜色会根据你给出的css而改变。

_form页面中,您已将input typesubmit按钮一起使用,并与类btn css链接。所以提交按钮正在消耗css。