gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 12:30:48 27 4
gpt4 key购买 nike

通过点击索引提交按钮,“新值”的颜色会改变并保持灰色,这是已访问链接的颜色,而_form提交按钮保持无论如何都是相同的颜色白色。

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

你能帮帮我吗?

index.html.erb

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

_form.html.erb

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

values.css.scss

// 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;
}

脚手架.css.scss

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;
}
}

最佳答案

在索引页中,您使用的是 link_to元素,这会给你一个行为 <a> .你为 a 提供了 CSS作为

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

因此颜色会根据您提供的 css 发生变化。

并且在 _form您使用过的页面input typesubmit按钮,它与类 btn 相关联CSS。所以提交按钮正在使用该 CSS。

关于html - 如何使按钮保持相同的链接颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27673581/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com