Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8032563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:25:36+00:00 2026-06-05T01:25:36+00:00

Refer to the screenshot below, I have created a div to wrap another two

  • 0

Refer to the screenshot below, I have created a div to wrap another two div of image and text, then I use CSS position: absolute to make these div merge together.

However, I found that the button is not sensitive while testing on mobile devices, sometime I need to touch the button few time to take effect.

So, is there something wrong for my code and what is the best practice to create a button with image and text?

Thanks

enter image description here

<div class="r">
    <div class="a">
        <div class="i"><img src="store_btn_on.png" /></div>
        <div class="t">Shatin</div>
    </div>
    <div class="b">
        <div class="i"><img src="store_btn_off.png" /></div>
        <div class="t">Causeway Bay</div>
    </div>
    <div class="c">
        <div class="i"><img src="store_btn_off.png" /></div>
        <div class="t">Kowloon Bay</div>                            
    </div>
</div>

Update for the part of javascript

addButtonListener($("#store > .r > .a"), function(event, target){
        $("#some_content").css("display", "none");
        $("#other_content").css("display", "block");
        $(".r > .b > .a > img").attr("src" , "store_btn_on.png");
        $(".r > .b > .b > img, .r > .b > .c > img").attr("src" , "store_btn_off.png");
});

function addButtonListener(targets, job){
    if ("ontouchstart" in document.documentElement){
        targets.each(function(){
            $(this)[0].addEventListener('touchstart', function(event){
                event.preventDefault();
                $(this).attr({ "x": event.targetTouches[0].clientX, "diffX": 0, "y": event.targetTouches[0].clientY, "diffY": 0 });
                $(this).addClass("on");
            }, false);
            $(this)[0].addEventListener('touchmove', function(event){
                $(this).attr({
                    "diffX": Math.abs(event.targetTouches[0].clientX - $(this).attr("x")),
                    "diffY": Math.abs(event.targetTouches[0].clientY - $(this).attr("y"))
                });
            }, false);
            $(this)[0].addEventListener("touchend", function(event){
                $(this).removeClass("on");
                if ($(this).attr("diffX") < 5 && $(this).attr("diffY") < 5){ $(job(event, $(this))); }
            }, false);
        });
    }
    else {
        targets.each(function(){
            $(this).mousedown(function(event){ event.preventDefault(); $(this).addClass("on"); });
            $(this).mouseup(function(event){ event.preventDefault(); if ($(this).hasClass("on")){ $(job(event, $(this))); } $(this).removeClass("on"); });
            $(this).hover(function(event){ $(this).removeClass("on"); });
        });
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:25:37+00:00Added an answer on June 5, 2026 at 1:25 am

    I am not sure about the sensitivity of your button on mobile devices (you haven’t shown any of your code for handling click events), but I think it is better to write your HTML like this:

    <div class="r">
        <div class="button on">
            <span>Shatin</span>
        </div>
        <div class="button">
            <span>Bay</span>
        </div>
        <div class="button">
            <span>Bay</span>                           
        </div>
    </div>
    

    Then use CSS in your stylesheet:

    .button {
        background: url(http://domain.com/images/store_btn_off.png) no-repeat 0 0;
        /* Additional button styles */
    }
    
    .button.on {
        background: url(http://domain.com/images/store_btn_on.png) no-repeat 0 0;
    }
    
    .button span {
        color: #FFF;
        margin: auto;
    }
    

    This makes it easy to dynamically turn a button on or off just by adding or removing the on class.

    Although not necessary, you may also be interested in looking at CSS3 gradients to create simple gradient background images like that, and then degrade nicely to an image in browsers without any gradient support.

    The class names “r” and “b” are not very descriptive. Unless some HTML/CSS minifier put those there and you have proper names in your development code, I would consider giving your classes more descriptive names as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please refer to the image at: http://i50.tinypic.com/svgg2h.jpg I have defined CSS color(#000000) for my
Refer to the image below to understand what I'm trying to do. It should
Please refer to the image. If I use [self.tableView initWithFrame:CGRectMake(0, 0, 320, 320) style:UITableViewStyleGrouped];
Refer to this article: math-round-vs-hack We have Math functions optimized. We use (num+0.5)|0 instead
To refer to the root of a website in asp I use an ASP
Please refer to this post. I have become able to configure my web.config file
Please refer to this background question. After constructing this COUNT, how would I then
Please refer to the screenshot. I assigned Qswap to a matrix and when I
refer my below javascript code , how to count rows if i click add
I am using CodeIgniter 2.1.0 and MySQL database. I have uploaded an image through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.