我想向具有響應式設計的網頁添加通話支持按鈕。我只想在網頁處於移動視圖時才顯示該按鈕,並且在不是移動視圖時將其替換爲一行文本。僅當視圖響應時才顯示按鈕手機大小
我在顯示/隱藏響應式網頁的按鈕時遇到問題。
這裏是我的嘗試:
接觸頁:
<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