Give help. Get help.

  • # December 4, 2017 at 11:02 am

    Have a look at this pen:

    I have two issues with this code.

    The first is that the img’s and h1 elements aren’t center aligning even though I invoke margin: auto in three different locations. Why aren’t h1 and imgs aligning in the centre?

    The second issue is specifying the img to each transform and rotate uniquely. ‘one’ should transform 35 degrees, ‘two’ 225deg and ‘three’ 325deg. I’ve attempted to achieve this at lines 10, 15, and 19 in the CSS by adding subclasses, .one, .two, .three next to .site-logo:hover. When I uncomment those lines, the img’s are just frozen on the spot. What am I doing wrong here? How do I get each of the three img’s to be layered and rotate by a few degrees in different directions with mouse over?

    Thanks for your attention.

    edit: grammar correction

    # December 4, 2017 at 11:05 am

    Firstly, margin:auto has no centering effect on absolutely positioned elements.

    Secondly, the h1 IS centered but as it’s block level it’s 100% wide.

    What you need to do is center the text IN the h1…and text-align:center will do that.

    # December 4, 2017 at 11:07 am

    As for the just have bad selector.

    .site-logo:hover .two 

    will select .two which is a child of .site-logo

    What you want is .site-logo.two :hover…etc

    # December 4, 2017 at 12:54 pm

    Thank you for this reply, @paulie_d.

    I added text-align: center to the h1 element in my CSS. It looks great now.

    I changed the three .site-logo elements to look like this: :hover (and the same for ‘.two’ and ‘.three’) but now all three images are frozen:

    What am I doing wrong? I’m sorry if I miss understood your post, Paulie.

    # December 4, 2017 at 1:13 pm

    Oops..sorry ..typo .

    Try .site-logo.two:hover etc. without the space.

    But be aware that if these images are stacked, you can only hover the top one at a time.

    # December 4, 2017 at 2:25 pm

    As you explained, Paulie, since the imgs are stacked, its hard to animate the imgs below the topmost one. So I changed the img position to relative for testing purposes. That change is now present in my newest pen, linked to here:

    The .two and .three elements rotate and animate as expected. But .one is still frozen. I tried playing with the transform variables in degrees. It is still always idle. Any idea as to why? I am totally baffled.

    Thanks you, @paulie_d for your help and for your patience so far.

    # December 5, 2017 at 2:51 am

    Looks like a stacking issue..I’ve removed the positioning which seems to fix it.

    # December 5, 2017 at 5:38 pm

    Thank you, Paulie. This is an enormous help. I appreciate the time you spent reorganizing my code. It performs wonderfully.

    A final question: How easy would it be to have the images animate on mouse scroll, rather than hover? Like, when the user scrolls up and down the webpage, is it possible to have the images rotate 30 degrees back and forth using pure CSS? Or would this feature be in the category/realm of JavaScript?

    Thanks again, Paulie.

    # December 6, 2017 at 3:17 am

    Determining anything based on a scroll is a JS issue unfortunately.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.