CSS 按钮有边框
CSS Button has a border
我正在尝试为我的搜索表单定义一个自定义 css 按钮。我不明白为什么这个特定的按钮周围有一个奇怪的边框?我需要将其删除,但无法弄清楚它来自下面 css..code 和 fiddle 中的何处。
/* Define Search Button */
button.button-search::-moz-focus-inner { padding:0; border:0; } /* FF Fix */
button.button-search { -webkit-border-fit:lines; } /* <- Safari & Google Chrome Fix */
button.button-search { position:absolute; right:10px; top:8px; }
button.button-search > span {
background: #3399CC; /* Old browsers */
box-shadow:1px 1px 0 #a4a4a4;
display:block;
float:none;
width:88px;
height:32px;
line-height:30px;
text-align:center;
font-size:15px;
color:#fff;
text-align:center !important;
}
button.button-search span span { padding:0; float:none; }
button.button-search:hover > span {
opacity:0.8 !important;filter:alpha(opacity=80) !important;
box-shadow:1px 1px 0 #a4a4a4;
}
.header .form-search button.button-search { }
.header .form-search button.button-search > span { }
.header .form-search button.button-search:hover > span { }
.header .form-search button.button-search span span { }
.header .form-search button.button-search:hover span {}
<div class="header">
<div class="form-search">
<button type="submit" title="<?php echo $this->__('Search') ?>" class="button-search"><span><span>Search</span></span></button>
</div>
</div>
谢谢
按钮有边框,默认有背景。
去掉它们,就好了。
但我认为将 span 添加到按钮中是无效的。
解决方案在这里:(css)
button.button-search { background: transparent; border: none; position:absolute; right:10px; top:8px; }
如果您在代码上方添加以下代码,它将起作用:
button {
border: medium none;
margin: 0;
padding: 0;
}
此代码重置了浏览器中的一些默认样式。
发生这种情况是因为您需要通过定义自己的 class 来覆盖默认样式,例如 'change':-
<button type="submit" title="<?php echo $this->__('Search') ?>" class="button-search change"><span><span>Search</span></span></button>
button.button-search.change{
border:0;
padding:0;
}
已更新 fiddle :-http://jsfiddle.net/ynwypqw2/
您正在将 CSS 应用于按钮内的跨度,因此按钮的默认样式仍在使用:
摆脱所有混乱的<span>
,并且正如@Christoph在评论中所说,type="submit"
可以省略,因为它是按钮的默认功能:
<div class="form-search">
<button title="<?php echo $this->__('Search') ?>" class="button-search">Search</button>
</div>
将CSS应用于输入:
button.button-search::-moz-focus-inner { padding:0; border:0; } /* FF Fix */
button.button-search { -webkit-border-fit:lines; } /* <- Safari & Google Chrome Fix */
button.button-search { position:absolute; right:10px; top:8px; }
button.button-search {
background: #3399CC; /* Old browsers */
box-shadow:1px 1px 0 #a4a4a4;
display:block;
float:none;
width:88px;
height:32px;
line-height:30px;
text-align:center;
font-size:15px;
color:#fff;
text-align:center !important;
border:none;/*Removes the border*/
}
使用这个.button-search{ border: 0; padding: 0; }
如果我理解你的问题,你需要做这样的事情:
.button-search{border:0px;background-color:inherit;}
.button-search:focus{outline:none;}
看起来需要不同 html 结构的解决方案适合您。但要回答最初的问题,这里是 css 解决方案,让 button
尊重您的自定义样式:
button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 0;
border: 0;
}
这会告诉 Safari 和 Chrome (webkit)、Firefox (moz) 和符合标准的浏览器不要强制执行它们的默认 button
样式,然后确保没有填充或边框。
我正在尝试为我的搜索表单定义一个自定义 css 按钮。我不明白为什么这个特定的按钮周围有一个奇怪的边框?我需要将其删除,但无法弄清楚它来自下面 css..code 和 fiddle 中的何处。
/* Define Search Button */
button.button-search::-moz-focus-inner { padding:0; border:0; } /* FF Fix */
button.button-search { -webkit-border-fit:lines; } /* <- Safari & Google Chrome Fix */
button.button-search { position:absolute; right:10px; top:8px; }
button.button-search > span {
background: #3399CC; /* Old browsers */
box-shadow:1px 1px 0 #a4a4a4;
display:block;
float:none;
width:88px;
height:32px;
line-height:30px;
text-align:center;
font-size:15px;
color:#fff;
text-align:center !important;
}
button.button-search span span { padding:0; float:none; }
button.button-search:hover > span {
opacity:0.8 !important;filter:alpha(opacity=80) !important;
box-shadow:1px 1px 0 #a4a4a4;
}
.header .form-search button.button-search { }
.header .form-search button.button-search > span { }
.header .form-search button.button-search:hover > span { }
.header .form-search button.button-search span span { }
.header .form-search button.button-search:hover span {}
<div class="header">
<div class="form-search">
<button type="submit" title="<?php echo $this->__('Search') ?>" class="button-search"><span><span>Search</span></span></button>
</div>
</div>
谢谢
按钮有边框,默认有背景。
去掉它们,就好了。
但我认为将 span 添加到按钮中是无效的。
解决方案在这里:(css)
button.button-search { background: transparent; border: none; position:absolute; right:10px; top:8px; }
如果您在代码上方添加以下代码,它将起作用:
button {
border: medium none;
margin: 0;
padding: 0;
}
此代码重置了浏览器中的一些默认样式。
发生这种情况是因为您需要通过定义自己的 class 来覆盖默认样式,例如 'change':-
<button type="submit" title="<?php echo $this->__('Search') ?>" class="button-search change"><span><span>Search</span></span></button>
button.button-search.change{
border:0;
padding:0;
}
已更新 fiddle :-http://jsfiddle.net/ynwypqw2/
您正在将 CSS 应用于按钮内的跨度,因此按钮的默认样式仍在使用:
摆脱所有混乱的<span>
,并且正如@Christoph在评论中所说,type="submit"
可以省略,因为它是按钮的默认功能:
<div class="form-search">
<button title="<?php echo $this->__('Search') ?>" class="button-search">Search</button>
</div>
将CSS应用于输入:
button.button-search::-moz-focus-inner { padding:0; border:0; } /* FF Fix */
button.button-search { -webkit-border-fit:lines; } /* <- Safari & Google Chrome Fix */
button.button-search { position:absolute; right:10px; top:8px; }
button.button-search {
background: #3399CC; /* Old browsers */
box-shadow:1px 1px 0 #a4a4a4;
display:block;
float:none;
width:88px;
height:32px;
line-height:30px;
text-align:center;
font-size:15px;
color:#fff;
text-align:center !important;
border:none;/*Removes the border*/
}
使用这个.button-search{ border: 0; padding: 0; }
如果我理解你的问题,你需要做这样的事情:
.button-search{border:0px;background-color:inherit;}
.button-search:focus{outline:none;}
看起来需要不同 html 结构的解决方案适合您。但要回答最初的问题,这里是 css 解决方案,让 button
尊重您的自定义样式:
button {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
padding: 0;
border: 0;
}
这会告诉 Safari 和 Chrome (webkit)、Firefox (moz) 和符合标准的浏览器不要强制执行它们的默认 button
样式,然后确保没有填充或边框。