My problem is so simple, that I cannot believe that there is no HTML/CSS based solution for iOS 4 and above.
I have grid of images, each subtitled with a single line of gray text. The text is bordered by lines at the top and at the bottom.
When the user taps down on the element (the image or the subtitle) the text and the lines should change the color to white and resets the color, when he lifts the finger again. I would even be better, if an additional line would appear at the top of the image. The whole element is encapsulated in a div.
I already tried to use the CSS properties -webkit-tap-highlight-color, -webkit-active-link and :hover, :active on the div or various subelements, without any success so far.
As suggested I tried this document
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" href="highlight.css" />
<style type="text/css"></style>
<script type="text/javascript">
div = document.getElementById('element');
div.ontouchstart = function(){this.style.backgroundColor = '#fff';} // on tapping
div.ontouchend = function(){this.style.backgroundColor = '#000';} // on releasing
</script>
<title></title>
</head>
<body>
<div id="element">
<p>Dies ist noch ein Test.</p>
<p>Wenn man auf <a href="#">diesen etwas laengeren Link </a> tappt, sollte was passieren.</p>
</div>
</body>
</html>
with this style sheet
#element {
width:200px;
height:200px;
border:solid;
border-color:blue;
-webkit-user-select:none;
}
But this also seems not to work.
Since you’re not into JS – here’s the complete script for you:
Put it after your element’s tag.
Here something even better:
Put the code above in the
<head>element.All left to do is to add to your element theese atts:
e.g.
<div id='element' onmousedown='changeClr( "element" , "#f00" );' onmouseup='changeClr( "element" , "#000" );'></div>That code allows you to change color of any element by adding theese atts.