html - 当按钮处于活动状态时,我可以只缩小按钮的文本吗?
问题描述
我有单元格号码,我给了盒子阴影和填充,它看起来像一个按钮。因为它是可点击的,所以当“按钮”处于活动状态时,我更改了框阴影的设置,所以看起来你真的在按下它。为此,当您单击/触摸时,它会按比例缩小一点,但会同时按比例缩放数字和“按钮”。我想做的是在活动时只缩小数字,但我不知道如何。我试图将数字放在一个跨度中,但不适用于 :active 伪(我认为因为文本不可点击)。有没有其他方法或者我应该做一个按钮?
我给你代码和网页。该代码将呈现可怕的所以看看网页,在单元格号码。(请在移动模式下检查它。我首先将它构建为移动设备,还没有媒体查询。) 网页在这里
.cellnumber {
/* box-shadow */
box-shadow: 5px 5px 10px white inset, -2px -2px 10px rgba(30, 30, 30, .5) inset;
padding: 10px 15px;
padding-bottom: 3px;
border-radius: 10px;
transition: all .35s;
}
.cellnumber:active {
box-shadow: 5px 5px 20px rgba(30, 30, 30, .3) inset, -5px -5px 20px rgba(90, 90, 90, .1) inset;
transform: scale(.97);
}
.paolo {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 1px solid black;
padding: 30px 0;
padding-bottom: 55px;
margin-bottom: 50px;
}
.numeroandiconcell {
display: flex;
justify-content: space-around;
align-items: center;
}
.cellnumber {
text-decoration: none;
color: black;
font-size: 50px;
margin-top: 40px;
}
<div class="paolo">
<div class="numeroandiconcell">
<a class="cellnumber" href="tel:+393475924197">347 592 4197</a>
</div>
</div>
谢谢你!
解决方案
我已将文本包装在 a 中div
并将其scale
放在该 div 上,同时将阴影保留在.cellnumber
此作品上
.cellnumber {
/* box-shadow */
box-shadow: 5px 5px 10px white inset, -2px -2px 10px rgba(30, 30, 30, .5) inset;
padding: 10px 15px;
padding-bottom: 3px;
border-radius: 10px;
transition: all .35s;
}
.cellnumber div {
/* box-shadow */
transition: all .35s;
}
.cellnumber:active {
box-shadow: 5px 5px 20px rgba(30, 30, 30, .3) inset, -5px -5px 20px rgba(90, 90, 90, .1) inset;
}
.cellnumber:active div {
transform: scale(.97);
}
.paolo {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 1px solid black;
padding: 30px 0;
padding-bottom: 55px;
margin-bottom: 50px;
}
.iconandname {
padding: 10px 0;
text-align: center;
}
.contactname {
font-size: 50px;
position: relative;
top: 5px;
}
.numeroandiconcell {
display: flex;
justify-content: space-around;
align-items: center;
}
.cellnumber {
text-decoration: none;
color: black;
font-size: 50px;
margin-top: 40px;
}
.iconasmartphone {
position: relative;
top: 5px;
}
.tap {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
top: 20px;
}
.chiamaconuntocco {
font-size: 25px;
<div class="paolo">
<div class="numeroandiconcell">
<a class="cellnumber" href="tel:+393475924197">
<div>347 592 4197</div>
</a>
</div>
</div>
推荐阅读
- javascript - 设置状态不适用于反应组件中的多个 api 获取
- java - 我需要帮助在 Java 平台游戏中创建碰撞系统
- html - 为什么光标在按钮上没有改变
- apache-spark - load() 在 spark 中做了什么?
- javascript - 尝试更改特定字母的背景颜色
- json - 如何在 N1QL 中查看 couchbase 服务器中的文档树?
- intellij-idea - 如何为新的 JavaScript 框架配置 IntelliJ IDEA 或 WebStorm 以便我可以使用智能?
- python - 检查目标时出错:预期 dense_10 的形状为 (2,) 但得到的数组的形状为 (1,)
- javascript - 如何将“this”从 ClassA 传递到 ClassB?
- java - 检查 SQLite 数据库中是否存在几个值