Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Absolute Positioning of an Image

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #256541
    b2995
    Participant

    Hi Everyone!

    I need some help with CSS. I would like to place an image to the left of my search box (col-full) and under my secondary menu and have it lay on top of everything else (site-navigation). I’d like it to disappear on tablet/mobile size.

    Here’s a link to my development site: DiscountSalsaShoes.com/dev/

    I know more than a beginner but not this much to do this, and appreciate help in working this out.

    Theme: Storefront Pro & Page Builder
    Wordpress: 4.8

    #257023
    webinuse
    Participant

    Hi, it would be much easier if you give us more details. First what image? Do you want to change backgorund, or to place any image? And what do you mean by “lay on top of everything else”? Do you mean like above everything, or in front of everything?

    #257032
    b2995
    Participant

    Hi Korovjov123 –

    I want to place the image called shoe.png…

    • to the right of “widget woocommerce widget_product_search”,
    • under the “secondary-navigation”
    • I also want it to lay on top of the header and the navigation
    • But I want it to hide on mobile.

    Here’s a link to an image of what I’m trying to accomplish: http://discountsalsashoes.com/shoe_example.jpg

    Thank you!

    #257034
    Atelierbram
    Participant

    I would try to absolute position a pseudo-element in relation to the search widget, and use that as a wrapper for a background-image. Something like:

    .site-header .widget_product_search {
      position: relative; /* to position the pseudo-element against */
    }
    
    /* pseudo-element: */
    .site-header .widget_product_search:after {
      content: "";
      position: absolute; 
      z-index: 2;
      right: -400px /* edit this value */;
      top: -100px/* edit this value */;
      width: 400px /* whatever the width of your background-image */;
      height: 200px /* whatever the height of your background-image */;
      background-image: url(path/to/background-image.jpg);
      background-repeat: no-repeat;
      background-position: center center;
    }
    
    #257068
    webinuse
    Participant

    Atelierbram is right, this is the best and the easiest way to accomplish what you want. And if you want to remove it on mobile, all you have to do is make your media querie, or if you have breaking points already which I assume you do, use one of them:
    @media only screen and (max-width: 767px) {
    .site-header .widget_product_search:after {
    background image: none;}}

    #257107
    b2995
    Participant

    Ahhh! Perfect! I’m so easily entertained…LOL!

    Thanks guys! Works perfectly ;)

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.