html - 按钮填充不起作用

标签 html css button padding

我有一个图像横幅,我想在它上面添加一个按钮。该按钮是 HTML 格式,而不是图像。但是,问题是我无法将按钮移动到图像顶部。我相信这与按钮的边距有关。我已经在我的 Weebly 网站中实现了以下代码,尽管该按钮似乎非常适合编辑器,但在发布后,该按钮会显示在横幅的底部。这是我的 HTML 代码:

“margin:-70px”似乎是正确的,尽管它在发布后并不适用。那怎么了?是不是少了什么?

.btn_action_1 {
  border: 5px solid #000 !important;
  /* Change button border color */
  color: #000 !important;
  /* Change button text color */
  font-size: 22px;
  font-family: 'Ubuntu';
  line-height: 0;
  display: inline-block;
  padding: 10px 15px 10px;
  position: relative;
  text-decoration: none;
  z-index: 3;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.btn_action_1 span {
  left: 10px;
  position: relative;
  -o-transition: all .4s;
  -moz-transition: all .4s;
  -webkit-transition: all .4s;
  transition: all .4s;
}

.btn_action_1 .ico_arrow {
  background: url(ico_arrow_w.png) 0 center no-repeat;
  display: inline-block;
  height: 17px;
  width: 17px;
  position: relative;
  left: -12px;
  top: 0px;
  opacity: 0;
  filter: alpha(opacity=0);
  -o-transition: all .4s;
  -moz-transition: all .4s;
  -webkit-transition: all .4s;
  transition: all .4s;
}

.btn_action_1:hover {
  background: #000 !important;
  /* Change button background color when mouse over */
  color: #fff !important;
  /* Change button text color when mouse over */
}

.btn_action_1:hover span {
  left: -5px;
}

.btn_action_1:hover .ico_arrow {
  opacity: 1;
  filter: alpha(opacity=100);
  left: 5px;
}

@media (max-width: 479px) {
  .btn_action_1 {
    padding: 18px 30px;
  }
}

.btn_action_1:not(:hover)>.hover,
.btn_action_1:hover>.default {
  display: none
}
<img src="http://unlckpaypal.weebly.com/uploads/6/3/8/8/63884033/left_banner.png" style="margin: 10px 0px 0px 0px;width:440px;height:210px;">

<a href="http://unlckpaypal.weebly.com/trending-127809.html" style="margin:-70px 0px 0px 200px;width:180px;height:45px;" class="btn_action_1">
  <span>SHOP NOW</span>
  <i class="ico_arrow"></i>
</a>

最佳答案

把这段代码给padding: 10px 15px 10px;.btn_action_1 span这个类,我觉得可以用

.btn_action_1 {
border: 5px solid #000 !important; /* Change button border color */
color: #000 !important; /* Change button text color */
font-size: 22px;
font-family: 'Ubuntu';
line-height: 0;
display: inline-block;
padding: 10px 15px 10px;
position: relative;
text-decoration: none;
z-index: 3;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.btn_action_1 span {
left: 10px;
position: relative;
-o-transition: all .4s;
-moz-transition: all .4s;
-webkit-transition: all .4s;
transition: all .4s;
}
.btn_action_1 .ico_arrow {
background: url(ico_arrow_w.png) 0 center no-repeat;
display: inline-block;
height: 17px;
width: 17px;
position: relative;
left: -12px;
top: 0px;
opacity: 0;
filter: alpha(opacity=0);
-o-transition: all .4s;
-moz-transition: all .4s;
-webkit-transition: all .4s;
transition: all .4s;
}

.btn_action_1:hover {
background: #000 !important; /* Change button background color when mouse over */
color: #fff !important; /* Change button text color when mouse over */
}

.btn_action_1:hover span {
left: -5px;
}
.btn_action_1:hover .ico_arrow {
opacity: 1;
filter: alpha(opacity=100);
left: 5px;
}
@media (max-width: 479px) {
.btn_action_1 {
    padding: 18px 30px;
}
}

.btn_action_1:not(:hover)>.hover,
.btn_action_1:hover>
.default {display:none}
<img src="http://unlckpaypal.weebly.com/uploads/6/3/8/8/63884033/left_banner.png" 
style="margin: 10px 0px -50px 0px;width:440px;height:210px; position:relative;">

<a href="http://unlckpaypal.weebly.com/trending-127809.html" 
style="margin:-30px 10px 10px 220px;width:180px;height:45px;  " 
class="btn_action_1">
<span>SHOP NOW</span>
<i class="ico_arrow"></i>
</a>

关于html - 按钮填充不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43000613/

相关文章:

php - 移动主题 Prestashop 中的单选按钮不起作用

css - 具有百分比宽度的响应式 CSS 三 Angular 形

javascript - 在滚动条上显示 float 导航栏

Android 动态创建按钮 : setOnClickListener doesn't work

javascript - AngularJS - 充当单选按钮的 3 按钮组

php - HTML 表格的 CSS 宽度问题

html - 如何在响应式设计中包含图像和文本部分?

javascript - 从内容可编辑的 div 中移除焦点

html - 如何将元素的背景扩展到其容器之外?

html - Bootstrap 特定按钮标签未反射(reflect) Css 属性