CSS div buttons not working on Iphone or Ipad

假如想象 提交于 2019-12-24 01:04:23

问题


I am working on a web base app for my school with different versions of CSS for handheld, tablet and desktop. I am using media queries for this. The app is almost done and it works correctly on almost all browsers and android. The app looks awesome on Iphone/Ipad however buttons do not work making the app useless in these devices.

This is what I have:

//Source code

<div id="signinbutton" class="blue_button">Sign In</div>

//desktop.CSS

.blue_button {
    width: 130px;
    height: auto;
    padding: 8px;
    margin: 0% auto 20% auto;
    background-image:url(../../images/bluebar5.png);
    color: #FFF;
    text-align: center;
    font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
    font-size: 14pt;
    font-weight: bolder;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px;
    cursor: default;
    }
.blue_button:hover {
    opacity: 0.7;
}

//Handheld.css (this overwrites css on desktop)

.blue_button {
    width: 260px;
    font-size: 18pt;
    background-image:url(../../images/bluebar6.png);
}

I tried applying the style to #signinbutton without success.


回答1:


You should use a <button> or <input type="button"> tag instead of a div. While the <div> button functionality may work in some browsers, it can be a bit of a hack compared to the traditional button tags




回答2:


You can wrap your div around <a> like this. It's perfectly valid with html5 now.

<a href="#"><div id="signinbutton" class="blue_button">Sign In</div></a>

You just need to adjust Reference: https://css-tricks.com/snippets/jquery/make-entire-div-clickable/




回答3:


Try adding to the style of the div {cursor:pointer}.



来源:https://stackoverflow.com/questions/15280596/css-div-buttons-not-working-on-iphone-or-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!