我只想为手机用户而不是桌面用户显示超链接。这是这样做的方法吗?
@media screen and (min-width: 480px)
{
<a href="xxxxx"> Test <a>
}
No.您不想将HTML添加到CSS,它将不起作用。
HTML:
<a class="formobile" href="0000000"> Phone # </a>
CSS:
a.formobile { display: none; }
@media screen and (min-width: 480px) {
a.formobile { display: block; /* or display: inline-block; or display: inline; depending upon surrounding markup */ }
}
- 在 HTML 页面中创建链接
- 使用设备宽度专门定位到这些分辨率和移动设备上。
请注意,我使用的是min-device-width
而不是min-width
。使用适合您项目的内容。
像这样的东西
a.mobile-only {display: none;}
@media screen and (min-device-width: 480px) {
a.mobile-only {display: inline;}
}