Been working on a site for a client and tried everything to get the green play button to scale with the parent graphic its positioned too. Don’t really want to use javascript and was hoping for a solution if anybody can help. If you load up the URL and scale your browser to tablet and mobile size you’ll see the green play buttons don’t respond.
The first thing I would suggest is to give the arrow a more reliable positioning context. You would think, by looking at it, that the arrow would be placed inside a box the size of the image behind it. If that were the case, it would be easy to position it in relation to that box and allow that positioning to adjust with the screen. As it is, though, the image is positioned relative to a fairly large, vaguely positioned box, which makes it a lot harder to work with.
Exactly Ralph.
I did think about this technique but don’t have a fixed size I can use. The same play button is also used on a number of different sized containers so one size will not fit all. I don’t really have that much control over the markup but need away to force some CSS on to the element(s) and make this work. Its like the play button is taken out of the work flow completely and has no relation to the containers below it.
I’ll see if i can find a solution and if you have any ideas let us know, thanks.
Well, it could, actually, as long as the container actually had the dimensions of the area the button needs to center over. I was going to set the image to
Cheers Ralph, seems like a good approach currently testing this now.
As it stands, the play buttons are already centred. Even with the solution above I still have the problem that the image does not scale (change size) when everything else does. Thats my main issue to get the play buttons to scale with the graphic they’re associated with when the window changes size, different device an so on.
Are you saying by using the above the image should now scale?
It will need tweaking when the media queries click in.
However, as Ralph pointed out your best approach would be to wrap the big image in a div with position:relative set and use that div as a point of reference for the play button. Then place an inner absolute element that can be set to the width and height of the relative div and then do something like.
div.imgholder{position:relative;zoom:1.0;display:inline-block}/* stacking context based on height and width of large image*/
.imgholder div{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
z-index:2;
text-align:center;
margin:0;
}
img.video-icon{
margin:auto!important;
width:20%;
height:20%;
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
However if you can’t manipulate the html that much then you are probably stick with the first approximate approach.
Cool Paul thanks.
I’ll give this a try and see if I can get things to work.
I can modify markup but lots of messing around due to the CMS I’m working with.
Thanks again and will let you know how things go, cheers.