简体   繁体   English

如何将按钮隐藏在图像文本后面,并使它们在所有设备上都位于同一位置?

[英]How to hide buttons behind image text and make them stay in the same place across all devices?

I would like to hide two buttons, which I have achieved using transparent. 我想隐藏两个按钮,这是我使用透明按钮实现的。

I've also managed to hide them behind two hand written words in a picture, post and search . 我还设法将它们隐藏在图片中的两个手写单词后面,并postsearch The problem is that when it comes to desktop, different screen sizes, mobile/tablet, different screen sizes/browsers, operating systems etc, the buttons don't match the text, being either too high or too low, depending on device etc. 问题是,当涉及台式机,不同的屏幕尺寸,移动/平板电脑,不同的屏幕尺寸/浏览器,操作系统等时,按钮与文本不匹配,根据设备等的不同,它们可能太高或太低。

It works if I set one place for mobile and one for desktop, but as soon as anything changes like screen size, the text and buttons mis-match so that the picture text becomes unclickable. 如果我为移动设备设置了一个位置,为桌面设置了一个位置,则可以使用该功能,但是只要屏幕大小等任何变化,文本和按钮都将不匹配,从而使图片文本变得不可点击。 It's the effect I'm trying to achieve which is like the user is clicking on handwriting when in fact it's just a hidden button on the image. 这是我想要达到的效果,就像用户单击手写,实际上它只是图像上的隐藏按钮一样。

Also tried to cut the buttons out of the image and use background: url but it didn't work and just cropped the image in the wrong place, hiding the word. 还尝试从图像上剪下按钮并使用background: url但是它没有用,只是将图像裁剪到了错误的位置,从而隐藏了单词。

The only solution I can think of is if there is some way of telling the browser not to move the image regardless of screen size etc. 我能想到的唯一解决方案是,是否可以通过某种方式告诉浏览器不要移动图像,而不管屏幕大小等。

.btn.btn:hover {color: transparent! important; background: 
transparent! important; border: none! important;}

btn.btn:active {color: transparent! important; background: 
transparent! important; border: none! important; box- 
shadow:none;}

.btn.btn {color: transparent! important; background: 
 transparent! important; border: none! important;}

Html HTML

<div id="content" class="main-container">
<section class="content-area  pt0 ">
<div id="main" class="" role="main">
<div id="shapely_home_parallax-3" class="widget 
shapely_home_parallax"><section class="cover fullscreen 
image-bg"><div class="parallax-window fullscreen" data- 
parallax="scroll" data-image-src="https://adsler.co.uk
/wp- 
content/uploads/2019/07/IMG_20190706_112754.jpg" 
data-ios-fix="true" data-over-scroll-fix="true" data-android- 
fix="true"><div class="align-transform"><div class="row">
<div class="top-parallax-section"><div class="col-md-8 
col-md-offset-2 col-sm-10 col-sm-offset-1 text-center">
<div class="mb32"></div><a class="btn btn-lg btn-white" 
href="https://adsler.co.uk/wp-user-test-dashboard-2. 
2/awpcp-place-ad/">Post</a><a class="btn btn-lg btn- 
filled" href="https://adsler.co.uk/search. 
adsler/">Search</a>                              
</div></div><!--end of row--></div>
</div></div></section><div class="clearfix"></div>
</div>
</div><!-- #main -->
</section><!-- section -->

Just so you can get more of a sense of what is meant, the page is: https://adsler.co.uk 只是为了您可以大致了解它的意思,该页面是: https : //adsler.co.uk

You can try to play with display: none and display: block tag arguments for your divs. 您可以尝试使用div的display: nonedisplay: block标签参数。 This probably will require using JavaScript to change the property your your buttons. 这可能需要使用JavaScript来更改按钮的属性。 Something along the lines of when the first button is clicked it's display style is changed to none, and when the second one is clicked the first one's style is changed to block. 单击第一个按钮时,其显示样式更改为无,单击第二个按钮时,第一个样式更改为阻止。 onclick = "myFunction();" should do the trick. 应该可以。 https://www.w3schools.com/js/js_functions.asp for reference on JS functions https://www.w3schools.com/js/js_functions.asp以获取JS函数的参考

It's the effect I'm trying to achieve which is like the user is clicking on handwriting when in fact it's just a hidden button on the image. 这是我想要达到的效果,就像用户单击手写,实际上它只是图像上的隐藏按钮一样。

A much more effective way of achieving this effect will be to use an HTML image map . 实现此效果的一种更有效的方法是使用HTML图像映射 Using an image map will allow you to create arbitrarily shaped regions on an image that can be clicked like links. 使用图像贴图将使您可以在图像上创建任意形状的区域,这些区域可以像链接一样被单击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM