我想向具有响应式设计的网页添加通话支持按钮。我只想在网页处于移动视图时才显示该按钮,并且在不是移动视图时将其替换为一行文本。仅当视图响应时才显示按钮手机大小
我在显示/隐藏响应式网页的按钮时遇到问题。
这里是我的尝试:
接触页:
<div>
<p class ="Call-Customer-Support">Call customer support at 555-555-5555. </p>
<div class="Rectangle">
<img class="call icon-image" src="images/call.png" />
<a class="Call-Support" href="tel:555-555-5555">Call Support</a>
</div>
</div>
凡在我的style.css:
.Call-Customer-Support {
width: 709px;
height: 18px;
font-family: BentonSans-Bold;
font-size: 16px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin: 50px auto;
}
.Rectangle {
width: 292px;
height: 57px;
border-radius: 8px;
background-color: #0e74af;
margin: 50px auto;
}
.call {
width: 24px;
height: 24px;
object-fit: contain;
margin-left:72px;
margin-top:16px;
vertical-align:middle;
float: left;
}
.Call-Support {
width: 116px;
height: 23px;
font-family: BentonSans-Regular;
font-size: 20px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin-left: 8px;
vertical-align:middle;
text-decoration: none;
float:left;
display:block;
margin-top:17px;
}
,并在我的responsive.css:
@media only screen and (max-width: 767px) {
.Rectangle {
width: 292px;
height: 57px;
border-radius: 8px;
background-color: #0e74af;
margin: 50px auto;
}
.call {
width: 24px;
height: 24px;
object-fit: contain;
margin-left:72px;
margin-top:16px;
vertical-align:middle;
float: left;
}
.Call-Support {
width: 116px;
height: 23px;
font-family: BentonSans-Regular;
font-size: 20px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin-left: 8px;
vertical-align:middle;
text-decoration: none;
float:left;
display:block;
margin-top:17px;
}
}
@media only screen and (max-width: 479px) {
.Rectangle {
width: 292px;
height: 57px;
border-radius: 8px;
background-color: #0e74af;
margin: 50px auto;
}
.call {
width: 24px;
height: 24px;
object-fit: contain;
margin-left:72px;
margin-top:16px;
vertical-align:middle;
float: left;
}
.Call-Support {
width: 116px;
height: 23px;
font-family: BentonSans-Regular;
font-size: 20px;
font-style: normal;
font-stretch: normal;
color: #ffffff;
margin-left: 8px;
vertical-align:middle;
text-decoration: none;
float:left;
display:block;
margin-top:17px;
}
}
对于所有其他尺寸,我设定了本身性质:
.Rectangle {visibility:hidden}
.call {visibility:hidden}
.Call-Support{visibility:hidden}
但是,它有上显示的项目的可见性没有任何影响......
是您可以自由使用引导程序? –
我认为你需要在响应式CSS中明确地将可见性设置为'visible',否则它只会继承'hidden' ..('visibility:hidden'将隐藏该元素,但它仍然会占用该元素的物理空间,“display:none”将隐藏并且不呈现该元素)。 – Goombah