admin管理员组文章数量:1406720
I have a responsive grid with 20 images that when touched or clicked open a larger, full-sized corresponding image in a slideshow.
However:
I need to disable that link to the slideshow on mobile only (<=480).
Here is how it works:
<div class="box">
<div class="boxInner">
<a href="slideshow_illustration.html?er_col=0"/><img src="_assets/grid_illustration/geisha.jpg">
<div class="titleBox">Geisha</div>
</div>
</div>
Please know: I'm just a photographer/artist struggling to build a responsive personal site, so you will have to talk to me like I'm 10 years old.
Thanks in advance for any time and patience.
I have a responsive grid with 20 images that when touched or clicked open a larger, full-sized corresponding image in a slideshow.
However:
I need to disable that link to the slideshow on mobile only (<=480).
Here is how it works:
<div class="box">
<div class="boxInner">
<a href="slideshow_illustration.html?er_col=0"/><img src="_assets/grid_illustration/geisha.jpg">
<div class="titleBox">Geisha</div>
</div>
</div>
Please know: I'm just a photographer/artist struggling to build a responsive personal site, so you will have to talk to me like I'm 10 years old.
Thanks in advance for any time and patience.
Share Improve this question asked Jul 9, 2013 at 2:51 Stickup ArtistStickup Artist 1191 gold badge2 silver badges10 bronze badges2 Answers
Reset to default 4Depending on what you're trying to acplish, one way to do it without javascript is to use pointer-events
. This basically disables clicking on the element.
@media only screen and (max-device-width: 480px) {
.boxInner a {
pointer-events: none;
}
}
Include jquery in your site by including this in your page
<script src="//ajax.googleapis./ajax/libs/jquery/1.10.1/jquery.min.js"></script>
Then write a small script like this:
<script type="text/javascript">
$(document).ready( function() {
if (screen.width <= 480) {
$('.boxInner a').on('click', function (event) {
event.preventDefault();
});
}
});
</script>
This should test if the screen is <= 480, and disable the links if it is.
本文标签: javascriptHow to disable a href when media query detects specific browser sizeStack Overflow
版权声明:本文标题:javascript - How to disable a href when media query detects specific browser size - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745040712a2639056.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论