Another css margin padding

The relative container simply sets the stacking context fro the absolute element. All nested absolute elements will be placed in respect of this parent. It is basic css and there’s nothing complex to it that you wouldn’t use in any other similar situation.

As usual context is the key and there are often many different ways to do something in CSS but it all depends on the job in hand as to which approach is best.

It would be fine inside a flexbox assuming that the anchor is not a flex item (refer to ‘context is the key’ quote above :)).

FileZilla was not my friend. Skill deficiency on my part resulted in losing my source. http://www.GamesOnHorses.com is now active. Non-trivial work remains, but it should function for curiosity purposes.

Critique welcome of course

I have not taken a close look at the code, but just how the site responds to changing sizes.
The obvious thing is the header image. You need to add max-width: 100% to the h1 img though the title is a bit small at mobile size. Maybe swap the image out with a <picture> at small size to lose the surrounding pictures for just the title box.

The other thing that needs work is the menu backgrounds. A quick fix is to change background-size: 100% to background-size: 100% 100%, that will result in a bit of aspect squish/squash which I would not normally advocate, but I think you will get away with that here, it’s better than what you have.

Thank You SamA74 for the cogent feedback. I was struggling with what to do about the H1 image. I had not considered your swap-out approach. What an elegant solution.

Problem is that the heading is in the html as an img src=, not the css. I had trouble with getting my h1 text aligned into a background-image as the screen re-sized. So I chose to go with a static image. I knew it was a kludge at the time. But I am still not sure how to get around it as much as I would like my html h1 to be text.

Will change the background size as you suggest.

You can use the <picture> element to do this:-

Thanks for the clue.

So I made the changes to the landing page and it seems to work with one caveat.

When I use the ctrl->shift->I in Chrome to simulate mobile devices, it does not swap the src. So I need to do some more research on <picture> before I propagate the change to my other pages.

Can you post the code you tried with picture?
Something like this should work:-

    <picture>
        <source media="(min-width: 600px)" srcset="images/for-large-screen.png">
        <img  src="images/for-small-screen.png" alt="Games on Horses">
    </picture>
<h2>
                <picture>
                   <source media="(min-width: 900px)"; srcset="img/h1banner.png";>
                    <source srcset="img/h1nameonly.png">
                  <img src="img/h1banner.png" alt="Games on Horses">
                </picture>
</h2>

also, what is your best-practices opinion on using the w3-include-html attribute?

Try it like I have above. For 2 images you should not need 2 sources. Put the default image in the img and the alternative in the source with the media condition.

It’s not something I have ever dealt with, I use php includes.

Symptoms remain the same. fyi the main image, h1banner.png is 979px x 478px . The smaller, h1nameonly.png is 468px x171px

code:

Games on Horses

I just took another look at your site and the picture element seems to be working fine. The issue being that you have not added the max-width: 100% rule to the image as I suggested.
I initially tried in Firefox, that worked, then in Chrome, there is works changing the browser width, but not in dev tools for some reason.
I have a site using the element almost the same set up as that (where I copied the example code from) and that changes in Chrome dev tools. I can’t think why this should be. :confused:
The best thing would be to check on actual devices.

:bulb:
Just spotted where you are going wrong.
You don’t have the viewport meta tag in the document head. Add it.

<meta name=viewport content="width=device-width, initial-scale=1">

Just a reminder, be aware that IE11 does not support the picture element. Edge does, but Edge is not very widely used just yet.

http://caniuse.com/#search=picture

1 Like

It’s not such a big deal though, it just means that they always see the default image, so it doesn’t fail disastrously.

I neglected to upload the updated stylesheet to my host. So I didn’t exactly ignore you, but the effect is the same.

I added the meta tag from your later post as well. The Chrome simulator still does not do what I expect in shrinking the image, but it does substitute the smaller image for the larger

Grnadpa, please describe or take a screen shot of what the Chrome simulator shows. I have an idea what the trouble might be, but want more evidence.

I thought that was the problem, the meta tag should fix it.

That’s what max-width should fix.

In the Chrome simulator, the heading cropped right simulating dimensions 412 x 732. (In this case, the Nexus 6P). Similar results for all else. My wife was able to call up the site both on her Nook and her phone. Same symptoms.

Note also that the navigation text (Home, Games, Templates …) has lost sync with its background images.

FYI: Though not relevant for my header issue, I am using the flexbox option of css. So I will be changing the flex-direction and perhaps the order of the content.

I double checked and my stylesheet still has not uploaded. I am getting very frustrated with FileZilla. Will do it one more time.

Got it this time, But no effect. Even cleared the cache before reloading.

I was going to suggest that. But you still don’t have the max-width set. Adding that fixes it.