How to have an image and subscribe box side-by-side

oh dear, I’m lost again. I’m trying to add an image to my subscribe box but can’t figure how to set a height to the box. Can only see how to define p height at w3schools.

See: http://greensmoothie.com/test/1mst.php

I need for that subscribe box at top of page (.awbox)

(1) to be 180px high, same as image .subimgtop

(2) to have no border on left side

(3) border to begin where image ends, kinda how it looks now at the top but that’s accidental because the image is overlapping the border

(4) and in mobile, for the image & h3 to be at the top and the 2 subscribe fields below them. Almost the way it works now if I test it in iphone 4 portrait. But I need to intentionally tell the css that .awsub must drop below .subimgtop+.awhdr.

I hope the @media’s will all carry on working okay, with that new image!

thank you for your kind help - Val

Hey @valarcher assuming I’ve understood correctly, to answer your initial question, you can simply give the awdiv div a height. Because of the padding and border you have, you will want height: 151px.

thank you! That works for 886px & up, but at 553 the submit falls outside awbox, and at 810px it all works okay again – .boxrgt (postit) falls below .boxlft as per css – then at 553px submit falls outside awbox again, and in iphone 4 portrait both inputs and submit fall outside box.

(1) how do I get contents of .awbox to obey vertical-align:middle, for desktop screen? so it lines up in the middle next to image.

(2) how do I get .awsub to obey margin:0 auto, for desktop screen? so yellow submit button is center of screen.

(3) when they enter text into .input box, how can I tell the css it should be black? not color:#999.

(3) please is someone able to fix the @media for me?

(3) OR is there another way to add an image so it works in @media? e.g. could I use a column layout to have an image and opt-in box next to each other, and change the padding/margin values so there’s no space between them? If so, please can someone give me the css for that? I can’t figure how to keep hdr next to image for iphone portrait AND keep the inputs & submit inside .boxlft.

(4) Ideally is there a way to tell @media to make image smaller & smaller? so everything stays inside .boxlft all the time.

See: http://greensmoothie.com/test/1mst2.php

thank you!

I gave up on this - it’s too complicated :slight_smile:

Please don’t give up, try this changes in the relevant html and css. :slight_smile:

I (re)moved some html elements and the “awsub” class name in order to make better use of the table-cell displays:

<div class="boxsub">
    <div class="boxlft">
        <div class="awbox">
            <div class="subimgtop"></div>
            <div class="awhdr">
                <h3><span class="red3">—YOU know Top 12 Tips</span> but does your family? Give them this <span class="red3">colorful</span> ebook</h3>
                <form method="post" class="awsub aw" action="http://www.aweber.com/scripts/addlead.pl">
                    <input type="hidden" name="listname" value="rawhealing">
                    <input type="hidden" name="redirect" value="http://greensmoothie.com/misc/thanksub.php">
                    <input type="hidden" name="meta_redirect_onlist" value="http://greensmoothie.com/misc/thankhave.php">
                    <input type="hidden" name="meta_required" value="email">
                    <input type="text" name="name" class="input1" value="First Name" onfocus=" if (this.value == &#39;First Name&#39;) { this.value = &#39;&#39;; }" onblur="if (this.value == &#39;&#39;) { this.value=&#39;First Name&#39;;} ">
                    <input type="text" name="email" class="input2" value="Email" onfocus=" if (this.value == &#39;Email&#39;) { this.value = &#39;&#39;; }" onblur="if (this.value == &#39;&#39;) { this.value=&#39;Email&#39;;} ">
                    <input type="submit" name="submit" class="submit" value="Send Our Free Top 12 Tips">
                </form>
            </div>
        </div>
    </div>
    <div class="boxrgt postit">
        <h3><a href="http://greensmoothie.com/eat/teeth.php" target="_blank">Heal Your Teeth + Gums</a></h3>
        <p>* Do you get painful toothache?</p>
        <p>* Or bleeding gums?</p>
        <p class="red2">&gt;&gt; Read how I healed my teeth</p>
        <p class="foot"><a href="http://greensmoothie.com/eat/teeth.php" target="_blank">Stop Tooth Decay Today</a></p>
    </div>
</div>

In the CSS I changed some rules according to the new html and (re)moved and added some rules (I forgot to mark them). Hoping it will work as you intended:

.boxsub {
    display: table;
    width: 100%;
    table-layout: auto;
    margin-bottom: 30px;
}
.boxsub .boxlft,
.boxsub .boxrgt {
    display: table-cell;
    vertical-align: top;
}
.boxsub .boxlft {
    padding-right: 25px; /*space betw sub+postit*/
}
.boxsub .boxrgt {
    min-width: 300px;
    min-height: 170px;
}
@media screen and (max-width:810px) {
    .boxsub .boxlft,
    .boxsub .boxrgt {
        display: block;
        margin: 10px auto;
    }
    .boxsub .boxlft {
        padding-right: 0;
    }
}
.boxrgt input[type="text"] {
    color: #999; /*color in amazon search*/
}
.boxrgt input[type="text"]:focus {
    color: black;
    background: white;
}
.boxrgt .submit {
    color: blue;
    background: #ffffa0;
    cursor: pointer;
}
.awbox {
    display: table;
    padding: 12px 15px 12px 0;
    height: 152px;
    width: auto;
    vertical-align: middle;
    max-width: 600px;
    background: #f8f8f8;
    border: 1px solid #3eab34;
    border-radius: 20px;
}
.subimgtop,
.awhdr {
    display: table-cell;
    vertical-align: middle;
    padding-left: 15px;
}
.subimgtop {
/*    float: left; */
    background: url('imgpg/coverhalf.jpg') top center no-repeat;
    width: 148px;
/*    height: 180px; */
/*    padding: 0 15px 0 0; */
}
.awhdr h3 {
    display: block;
    margin: 0 0 12px;
    margin: 0 0 0;
    font: bold 1.1em "Comic Sans MS", sans-serif;
    color: #008b00;
}
.awhdr h3 a {
    font: 0.8em Arial, sans-serif;
    white-space: nowrap;
}
.awhdr h3 a:link,
.awhdr h3 a:visited,
.awhdr h3 a:active {
    color: blue;
    text-decoration: underline;
}
.awhdr h3 a:hover {
    background: #ffff8b;
    color: #e60026;
    text-decoration: none;
}
.awbox .awsub {
    display: block;
    text-align: center;
/*    width: 100%; */
/*    margin: 0 auto; */
}
.awsub input {
    display: inline-block;
    margin-top: 10px;
    padding: 4px;
    width: 13em;
    font-size: 80%;
}
/*
.awsub input[type="text"] {
    padding: 4px;
}
*/
.awsub .input1,
.awsub .input2 {
    border: 1px inset #ccc;
    color: #999;
}
/*
.awsub .input {
    margin: 0;
}
.awsub .input2 {
    margin: 8px 0 10px 5px;
    margin: 8px 15px 10px 0;
}
*/
.awbox .submit {
/*    margin: 0 auto; */
/*    padding: 4px 12px; */
    width: 14em;
    background: #ffffa0;
/*    font: 13px Arial, sans-serif; */
    cursor: pointer;
}
@media screen and (max-width:720px) {
    .awbox {
        margin: 0 6px 0;
        padding: 12px;
    }
    .awhdr {
        margin: 0 0 12px 5px;
    }
}
@media screen and (max-width:330px) {
    .awbox .submit {
    /*    padding: 4px; /* already is */
    }
}

Give it a shot!

3 Likes

wow @Erik_J I’m gob-smacked. I’m totally blown away that you stepped in and solved such a complicated problem. I’m SO GRATEFUL to you. Thank you!

I see why Sensei PaulOB said I must add “and Sitepoint Forums” when I put just “helped by Paul O’Brien” in the footer of every page! So it reads “helped by Paul O’Brien and Sitepoint Forums.”

I spent all yesterday on it - hours 'n hours 'n hours. I’m so totally blown away the way you got the image to change shape as the screen size changes. By accident of the image design, the words “Top 12 Tips” in the image always display! Even in iphone 4 portrait which cuts short all the other words.

It looks so beautiful the way you did it! It’s PERFECT :slight_smile:

Just one question: you’ve got &#39 - is it ok for me to change this to " (quote) or ’ (apostrophe)?

thanks million! - Val

2 Likes

I wish I’d headed this “how to have image in subscribe box” because I’m sure it’s a big problem for many. The major list providers - aweber, Thrive Leads, etc - don’t have that option of image & subscribe box side-by-side. They told me to use css.

I can edit the title for you if you want me to. :slight_smile:
Maybe to “How to have an image and set the specific height in a subscribe box”?

or: “how to have an image and subscribe box side-by-side”

Is there perhaps a way to link the image?

I tried this:

<a href="http://greensmoothie.com/subscribe" target="_blank" class="subimgtop"></a>

.subimgtop a:link,.subimgtop a:active,.subimgtop a:visited,.subimgtop a:hover{background:url('imgpg/coverhalf.jpg') top center no-repeat;width:148px;}

But it turns into a blank square (same green bgcolor as page) when I hover over it.

I’m trying to get the words I type inside .input to be grey and the words they type to be black

I tried this:

.awsub .input1,.awsub .input2{border:1px inset #ccc;}
.awsub .input1,.awsub .input2[type="text"]{color:#999;}
.awsub .input1,.awsub .input2[type="text"]:focus{color:black;}

But “First Name” displays in black.

Funny because it works higher up in the amazon and google boxes

.boxrgt input[type="text"]{color:#999;}/*color in amazon search*/
.boxrgt input[type="text"]:focus{color:black;}

Do you know why it doesn’t work here in awbox when I do the exact same thing?

See: http://greensmoothie.com/test/1mst2.php

Do you mean “placeholder” text?

Off Topic:

I’ve changed the topic title for you :slight_smile:

I went there but it seems placeholder is not standardized? whereas this has always worked x-browser (but doesn’t work for subscribe box - weird):

.boxrgt input[type=“text”]{color:#999;}/color in amazon search/
.boxrgt input[type=“text”]:focus{color:black;}

I’ve now uploaded the version where I’m trying to get the image to link to a page.

thank you!

Yes, there are different ways to do that. But I do not recommend the target attribute, it.s non standard nowadays and will only annoy your experienced visitors and confuse all others.

Please try this to make it a link while keeping it as a background image:

I would place the link in the “subimgtop” div and give it a descibing title of the reason to follow it.

<div class="subimgtop"><a href="http://greensmoothie.com/subscribe" title="Get your Free Plans and Free Raw Food Classes today!"></a></div>

The css changes for the link in “subimgtop” div:

.subimgtop,
.awhdr {
    display: table-cell;
    vertical-align: middle;
    padding-left: 15px;
}
.subimgtop {
    width: 148px;
    height: 100%; /* just to make sure the link can see the table-cell-height */
}
.subimgtop a {
    display: block;
    width: 100%;
    height: 100%;
    background: #486f80 url('imgpg/coverhalf.jpg') top center no-repeat; /* color to fill the height */
}
.subimgtop a:hover {
    outline: 1px solid blue;
    outline-offset: -1px;
}

Hope this solves the link issue. :slight_smile:

.subimgtop a:link, .subimgtop a:active, .subimgtop a:visited, .subimgtop a:hover {background:url('imgpg/coverhalf.jpg') top center no-repeat; width:148px;}

But it turns into a blank square (same green bgcolor as page) when I hover over it.

It seems you replaced the “subimgtop” div with the link and gave the class to the link, so the css selector became wrong. :wink:

Thank you! This works perfectly, I’m very grateful :slight_smile:

I know, but problem is wordpress still uses it and css hasn’t given us any other option - for the times when I don’t want reader to get lost on my site.

Just one problem-- when testing on iphone, the blue outline stays after clicking the image, both when I’m still on the link page and when I’ve x’d out of it.

I tried this:
.subimgtop a:link,.subimgtop a:active,.subimgtop a:visited{outline:none;}
.subimgtop a:hover{outline:1px solid blue;outline-offset:-1px;}

but did not work. Or maybe it doesn’t work because my iphone never obeys me when I tell it to clear cookies & history.

Meantime, I just deleted it in hover since that blue outline looks funny after clicking the link. I know that if I didn’t use target, that might solve the problem! But I use it so often throughout my site…

Are you sure you’re seeing outline and not text-decoration?

yes 'cause I don’t have any text-dec defined in that div! I’m happy to have no outline when they hover over image, I actually prefer it with none.

It’s an accessibility issue.

1 Like