首页 > 解决方案 > (html+css) 手机上的电话按钮分成两行,我怎样才能让它响应?

问题描述

我正在尝试使电话按钮在移动设备上响应。

在我浏览器的开发人员工具中,每个手机屏幕分辨率的一切似乎都很好,但是当我从手机访问该网站时,电话号码被分成 2 行,而不是在一个框中设置一行。

例子

html

<a href="tel:+972504751410" class="call call1" id="call call1"> 050-475-1410 </a>

CSS:

* {
  margin: 0;
  padding: 0;
}

body {
  overflow: scroll;
  margin: 0;
  font-size: 17px;
  color: black;
  line-height: 1.4;
}

@media only screen and (max-width: 2000px) {
    .call {
    /*Your styles on small screen - example only*/
    width: 200px;
    font-size: 30px;
    .span{display: inline;}
    }
}
@media only screen and (max-width: 600px) {
    .call {
    /*Your styles on small screen - example only*/
    width: 150px;
    font-size: 25px;
    .span{display: inline;}
    }
}

@media only screen and (max-width: 370px) {
    .call {
    /*Your styles on small screen - example only*/
    width: 125px;
    font-size: 20px;
    .span{display: inline;}
    }
}

@media only screen and (max-width: 330px) {
    .call {
    /*Your styles on small screen - example only*/
    width: 120px;
    font-size: 20px;
    .span{display: inline;}
    }
}

.call {
  color: #2c3e50;
  background: none;
  border: 1px solid #2c3e50;
  text-align: center ;
  padding: 10px, 20px;
  margin: 5px;
  font-family: font1;
  text-decoration: none;
  position: relative;
  cursor: pointer;
  top: 2px;
}

标签: htmlcss

解决方案


HTML 将连字符文本视为单词,这就是它们在小屏幕上分解的原因。

采用white-space: nowrap;

您也可以使用这些连字符uni-code &#x2011;&#8209;


推荐阅读