Suuuuper old question, but since I found it while searching for this answer myself, you can achieve this with a slight html re-structure and some simple CSS. Make the button the last child of a parent div, make it cover the div, and make it transparent.
I'm assuming you finished your website 9 years ago, but I'll explain this in full anyway in case others stumble across this in another 9 years.
HTML
<div class="buttonParent">
<div class="buttonNormalLargeLeft"><!--#--></div>
<div class="buttonNormalLargeCenter">Search Flights</div>
<div class="buttonNormalLargeRight"><!--#--></div>
<button class="button" type="submit"></button>
</div>
CSS
.button{
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background: transparent;
border: none;
}
You could also use opacity: 0 instead of a transparent background and no border, but that removes your ability to tab to it.
You still have access to .button:hover
, .button:active
and .button:focus
for the button itself, which can be used, for example, to add a background to the button itself with a very low opacity for a simple hover effect.
Or, if you want to go a little further down the rabbit hole, you can directly add or replace classes on the parent object, this will allow you to overwrite the previous classes and do whatever you want to the display of the button.
Non-JS
<button class="button"
onclick="this.parentElement.classList.replace('buttonParent', 'buttonParentClicked')"
onblur="this.parentElement.classList.replace('buttonParentClicked', 'buttonParent')"
type="submit"></button>
For example, ".buttonParentClicked .buttonNormalLargeLeft"
will override the CSS you have for .buttonNormalLargeLeft
, so you can use it to completely change the images and styles you have there.
And of course, if that's still not enough and you need more functionality on the parent, you can do whatever you want with JS.
HTML
<button class="button" onclick="myFunction()" type="submit"></button>
JS
myFunction(e){
const parent = e.target.parentElement;
//whatever you want to parent;
}