1 / 6
Oct 2016

I would like my side-by-side Add to Cart and View Cart buttons to be aligned, even after a variant drop-down list.



The vertical layout for each of our products is:

1. Product name

2. Product image

3. (Optionally) Drop-down list for variants

4. (Optionally) Text field for variation

5. Product description

6. Side-by-Side Add to Cart and View Cart buttons



If I have no variant drop-down list, there is no HTML form element and the buttons are perfectly aligned.

If I have a variant drop-down list, there is an HTML form element that I edited to contain both buttons and the buttons are badly misaligned.

On my View Cart button, I added the following kludge to compensate: style="margin-top: -20px;"



Much later, I discovered the following page and thought my problems would be solved:

3http://www.e-junkie.com/ej/troubleshooting-shopping-cart.htm3

The text said:

As soon as I add E-junkie cart to my site, my site layout gets messed up.

In the VIEW CART button code please add:

function EJEJC_config() {

EJEJC_INITCSS = false;

}



If EJEJC_config () {} already exists in your code, then simply add EJEJC_INITCSS = false; line to it.



I have tried positioning the code above in various parts of my VIEW CART button code to no avail.



Here's my unedited VIEW CART button code:

<a href="1https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2&cl=549901" target="ejejc" class="ec_ejc_thkbx" onclick="return EJEJC_lc(this);"><img src="https://www.e-junkie.com/ej/ejview_cart.gif" border="0" alt="View Cart"></a>

<script type="text/javascript">

function EJEJC_lc(th) { return false; };

</script>

<script src="https://www.e-junkie.com/ecom/box.js" type="text/javascript"></script>



What should the VIEW CART button code look like instead OR is there a different solution?



Thanks!

  • created

    Oct '16
  • last reply

    Oct '16
  • 5

    replies

  • 1.7k

    views

  • 2

    users

  • 9

    links

First, bear in mind you do NOT need a View Cart button for every single Add to Cart button. You only need one copy of View Cart code per entire page that has any number of Add to Cart buttons, so a good place for that would be in a common header, footer, or sidebar area that appears on every page.



That said, if you'd still prefer to have a View Cart next to each Add to Cart, you still only need one copy of the SCRIPT portion of View Cart code on each page:



<script type="text/javascript">

function EJEJC_lc(th) { return false; };

</script>

<script src="https://www.e-junkie.com/ecom/box.js" type="text/javascript"></script>



...then you can duplicate your actual View Cart button wherever you want it to appear:



<a href="https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2&cl=54990" target="ejejc" class="ec_ejc_thkbx" onclick="return EJEJC_lc(this);"><img src="https://www.e-junkie.com/ej/ejview_cart.gif" border="0" alt="View Cart"></a>



The Add to Cart and View Cart buttons should normally line up just fine if you put the View Cart code just inside the </form> tag of any Add to Cart code that has option menus or text fields, like so:



<form action="https://www.e-junkie.com/ecom/gb.php?c=cart&cl=54990&i=XXXXXX&ejc=2" method="POST" target="ejejc" accept-charset="UTF-8">

<input type="hidden" name="on0" value="Choose">

Choose:<br>

<select name="os0">

<option value="This">This</option>

<option value="That">That</option>

</select><br>

<input type="image" src="https://www.e-junkie.com/ej/ejadd_to_cart.gif" border="0" alt="Add to Cart" class="ec_ejc_thkbx" onClick="return EJEJC_lc(this.parentNode);">



<a href="https://www.e-junkie.com/ecom/gb.php?c=cart&ejc=2&cl=54990" target="ejejc" class="ec_ejc_thkbx" onclick="return EJEJC_lc(this);"><img src="https://www.e-junkie.com/ej/ejview_cart.gif" border="0" alt="View Cart"></a>

</form>



If you've done that and aren't seeing them line up neatly, your site probably has some CSS that styles INPUT elements differently from IMG elements, so that would be for you to sort out. If you can provide a link to your sales page where the misalignment appears, we may be able to help you with that.

Thank you.



We suspect that many of our clutterer/hoarder customers would get distracted or lost in a store that consists of separate pages for each product. Consequently, we built our store on a single page with one accordion per product. Customers see View Cart for each product category AND the expanded product.



Thanks for helping me tighten up the code. I've removed the redundant javascript from each accordion and now have it only once at the top of the page. It works fine.



The Add Cart and View Cart buttons you show above are stacked, not side-by-side as we desire.



The Professionals category in our store is here: 1https://clutterersanonymous.org/store-usa/#professionals1



The second product in the Professionals category (Leaflets -- Set of 9 Identical) shows the persistent misalignment problem now that I've commented out my corrective kludge code.

This CSS rule appears to be the culprit, in one of your site's CSS files at /wp-content/uploads/ultimatum/template_2.css:



img {

vertical-align: middle;

}



The misalignment is happening because that rule is telling browsers to align IMG elements with the middle of any text that could appear left/right of the image, but INPUT elements (like our Add to Cart button for items using Variations/Variants) still have the default alignment with the baseline of surrounding text. This page explains more about the vertical-align property in CSS:

https://css-tricks.com/what-is-vertical-align/



There's a few ways you could resolve this, depending on how it may affect other aspects of your site layout. One way is to delete that rule, or just comment it out to disable it like so:



/* img {

vertical-align: middle;

} */



Another way is to apply the rule to all INPUT elements (as well as IMG elements), like so:



img, input {

vertical-align: middle;

}



Another way is to apply the rule just to E-junkie Add to Cart INPUT elements (as well as IMG elements), like so:



img, input.ec_ejc_thkbx {

vertical-align: middle;

}



Finally, yet another way is to add a style attribute with that CSS declaration in the Add to Cart button tag itself, like so:



<input src="https://www.e-junkie.com/ej/ejadd_to_cart.gif" alt="Add to Cart" class="ec_ejc_thkbx" onclick="return EJEJC_lc(this.parentNode);" border="0" type="image" style="vertical-align: middle;">

Thank you so very much! I really appreciate how thorough you've been.



I noticed but didn't know what to do about the:

img {

vertical-align: middle;

}



When I've had a chance to implement one of the options you describe above, I'll let you know the (happy) outcome.

I added the CSS and removed all my kludge code. It works magnificently. Thank you!