调整移动按钮的大小

Resize Buttons for Mobile

我正在尝试将我网站上当前的 CSS 按钮设置为移动设备实际大小的 2 或 3 倍。我运气不佳

样式

.all-news-btn {
background: #666666;
background-image: -webkit-linear-gradient(top, #666666, #333333);
background-image: -moz-linear-gradient(top, #666666, #333333);
background-image: -ms-linear-gradient(top, #666666, #333333);
background-image: -o-linear-gradient(top, #666666, #333333);
background-image: linear-gradient(to bottom, #666666, #333333);
-webkit-border-radius: 3;
-moz-border-radius: 3;
border-radius: 3px;
font-family: Arial !important;
color: #ffffff !important;
font-size: 12px !important;
padding: 7px 8px 7px 7px;
text-decoration: none;
margin-left: 3px;
}

.all-news-btn:hover {
background: #666666;
background-image: -webkit-linear-gradient(top, #666666, #000000);
background-image: -moz-linear-gradient(top, #666666, #000000);
background-image: -ms-linear-gradient(top, #666666, #000000);
background-image: -o-linear-gradient(top, #666666, #000000);
background-image: linear-gradient(to bottom, #666666, #000000);
text-decoration: none;
}

媒体查询

@media only screen and (max-device-width: 480px) 
{
  .all-news-btn {width: 100%; font-size: 4.25em;}
}

工作示例

.bt{
  background: #333;
  color: #fdfdfd;
  min-height: 35px;
  margin: 0;
  border-radius: 3px;
  border: 0;
  line-height: 35px;
  text-align: center;
  margin: .5em 0 .5em 0;

}

a.bt{
  display: inline;
  padding: 7px 10px 7px 10px;
}

.bt:hover{
  background: #000;
}

@media only screen and (max-width:480px) { 
  .bt {
    width: 100%;
  }
  
  a.bt{
    display: block;
    padding: 0;
  }
}
<button class="bt">Button example</button>
<a class="bt">A example</a>
<input class="bt" type="button" value="Input example"/>


求解

您可以通过向主按钮 class 添加 min-width 属性轻松解决此问题。看看:

也在JSFiddle:)

Codepen

.all-news-btn {
  
  background: #666666;
  
  background-image: -webkit-linear-gradient(top, #666666, #333333);
  background-image: -moz-linear-gradient(top, #666666, #333333);
  background-image: -ms-linear-gradient(top, #666666, #333333);
  background-image: -o-linear-gradient(top, #666666, #333333);
  background-image: linear-gradient(to bottom, #666666, #333333);
  
  -webkit-border-radius: 3;
  -moz-border-radius: 3;
  border-radius: 3px;
  
  font-family: Arial !important;
  color: #ffffff !important;
  font-size: 12px !important;
  padding: 7px 8px 7px 7px;
  text-decoration: none;
  margin-left: 3px;

  min-width: 100px;
  min-height: 30px;
  display: inline;
}

.all-news-btn:hover {
  background: #666666;
  background-image: -webkit-linear-gradient(top, #666666, #000000);
  background-image: -moz-linear-gradient(top, #666666, #000000);
  background-image: -ms-linear-gradient(top, #666666, #000000);
  background-image: -o-linear-gradient(top, #666666, #000000);
  background-image: linear-gradient(to bottom, #666666, #000000);
  text-decoration: none;
}

 @media only screen and (max-width:480px) { 
  .all-news-btn {width: 100%; font-size: 4.25em; }
}
<button class="all-news-btn">Button example</button>
<input class="all-news-btn" type="button" value="Input example"/>