Place image arbitrarily over another image using css - html

There are several similar questions posted, but none that I found addresses my situation.
I would like to list items for sale, each in their own div. When an item sells, I'd like to place a transparent "sold" banner over any such item without fully obscuring the image. I will need to delegate someone else to add the "sold" banner in the code without the need for me to do this. So the simpler the method, the better.
Most, if not all, solutions on this site recommend creating the overlapping banner image in an absolutely positioned div. That secondary div contains an img src. This is looking like a lot more code to confuse the helper.
I gather it would be semantic and a lot easier if the transparent SOLD banner were a background. If I'm not mistaken, then all that would be needed is a simple class to add to any existing div. For example:
<div><img src="folder/item3.png"></div>
... becomes
<div><img src="folder/item3.png" class="sold"></div>
... thus doing away with a second div to contain the SOLD graphic. I tried this, and it appeared to work, but the banner remained stubbornly behind the item and no amount of Z-indexing and absolute positioning would get it out front where it belongs. (Actually I can't absolutely position this anyway since it interferes with the overall layout.)
I hope that someone can suggest a way to do this that solves the problem.

You cant use a background of the div containing the image because the background would always be under it. Unless you want to set the product image itself to a background and then just put the sold graphic into it as an image.
What I would do is, firstly you need your div containing your image to be position:relative. Then put another div inside it for the sold icon which is positioned absolute. z-index the sold icon above it.
e.g: http://jsfiddle.net/z2V2B/1/
html
<div class="imgholder"><div class="soldicon"></div><img src="http://s3-us-west-2.amazonaws.com/hypebeast-wordpress/image/2009/07/huf-converse-product-red-skidgrip-1.jpg" width="250"></div>
<div class="imgholder sold"><div class="soldicon"></div><img src="http://s3-us-west-2.amazonaws.com/hypebeast-wordpress/image/2009/07/huf-converse-product-red-skidgrip-1.jpg" width="250"></div>
css
.imgholder {position:relative; z-index:1;}
.soldicon {position:absolute;
z-index:2;
top:0;
left:0;
width:177px;
height:138px;
background:url(http://www.flq.co.nz/images/icon-sold.gif) no-repeat top left;
}
.sold .soldicon {display:block!important;}
.soldicon {display:none;}
-- ADDITIONAL 30/05/14--
If the SOLD label is overlapping the image -- which was originally linked to another page
...dit the code so that the sold div also has a link inside it to the same place as the image. Then add the following css:
.soldicon a {text-indent:-9000px; display:block; width:100%; height:100%;}
what this will do is create an invisible link (because the text will be indented off the page that is the full width and height of the sold icon div - it will seemlessly be as if the whole image is clickable again and not obscured by the sold icon

Related

Tumblr Header & Feed Spacing

I recently purchased the Margaret Studio theme from themecloset on Tumblr.
Once I added my own logo it cut off the first image on my blog with a white strip that must be the 'background' of my logo ( even though it's a transparent png). I would love to be able to fix this.
The main option I think would be to create a bigger space between my header and first post?
If you're wanting to create spacing between elements vertically, I'd add a margin-top:2%; to the lower of the elements.
If you're able to identify the <div> element which you'd like to move further down, you can add some inline styling to the div:
<div style="margin-top:2%;">
Or if you have access to the CSS, you could add an id to the div element and add the margin that way:
<div id="divIWantToMove">
and in the CSS sheet:
#divIWantToMove {
margin-top:2%;
}
You can play around with spacing using the W3 schools site :)
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_css_margin
(obviously the 2% I've referenced here can be swapped out for any number depending on how big of a margin you're looking to create)

How to place Div below my iFrame video

I currently have a iframe video and sitting on top of this are 4 clickable images. Below this, I want to have a contact Me page, however, the problem I am facing is How to get my Contact Me div blow the iframe video. Can someone Help me sort this problem out? Currently, on my codepen, you will see that i have applied a linear gradriend which is where the video is to be placed, and even though I have a Contact Me div in place, it is not placed in the top left hand corner, behind the iframe video, and I want it to be below the div, totally separated from it.
You can see my code on my Codepen, here
and this is what i currently have :
.
As you can see from the screen shot, this is the front page, but the "contact me" div is placed behind the video, in the top corner... can someone help me fix this issue?
You have too many elements with absolute positioning. You don't need all of that.
To position an element absolutely relative to its parent element all you have to do is add position: relative to the parent and position: absolute to the child.
And because you're positioning everything absolutely, elements are losing their height and it's why your contact div is moving to the top because the flow of the page is broken, and therefore, your contact div doesn't really see elements above it. Plus, you have color: white on the body and that applies to everything on your page including the contact div. change it and you'll find your contact on top of your header.
If you need more info I'm happy to help.
Your contact header is there. It is in the top left corner, but it is white (at least that is what I see on the code link)Give the <h1> a style color to help make it stand out, <h1 style="color:blue;"> etc. Also move the div to above the image in your code. That should also help.

Image Overlay Using Bootstrap?

I am currently using bootstrap and have a 3x3 grid of images. They are 200x200 images and I have looked EVERYWHERE to try and find a way to get an overlay to work on them. I only recently started writing code.
Serenbe.com has exactly what I am looking for about halfway down the page (also a 3x3 grid). The photo brightens, and a logo appears over it when you run your cursor over it. However, I would settle for text/links if a photo is not possible or too complicated. Right now absolutely nothing is working.
My images are arranged in a div within a container. The div takes up 6 columns. And the only styling I have applied is removing the padding so that it touches the edge of the page.
Any suggestions? I am 100% lost here, anything helps.
Thanks!
Have you heard of using hover with your css? :) it's pretty cool and I think that's what the site is using for its images.
An easy way to do what you want for beginners is I would have two pictures. One being the original and the second one with the effect you want. For serenbe it seems like they just added the logo on top using photoshop, then changed the opacity of the photo.
I would then wrap your img in a div and then do something like this in your css:
.customdiv{
height:200px;
width:200px;
background-image:url("imagelinkhere");
}
.customdiv:hover{
background-image:url("newimagehere");
opacity:.5;
}
What this does is change the content in your div to the new picture when you hover over the div, then apply the opacity on the image.
These are just a few tips to help you get started! Good luck

Absolute positioned image in Relative div is breaking page layout

I have an image with position:absolute;right-300px; inside a container with position:relative; as I want the image to come out of the div and off to the right.
You can see it working here. It's the first large image on the right.
The problem I have, is this is breaking the overall page layout and causing a vacant white space to the right of my page that can be side scrolled to.
If I put overflow:hidden; on the container div it will hide the rest of the image and I need the image to come out and be entirely visible.
Anyone have any suggestions for a way around this?
I tried writing up an example but I putting the whole page up seemed better
http://ciaranhanrahan.com/test/
Cheers!
I want the image to come out of the div and off to the right
Studying your page layout, it appears the image doesn't need to be in the <div> at all.
You could give the <img /> a position:absolute;.
Then, you can include the <img /> markup anywhere in your HTML source.
For instance, it's a 495kB image (ie. quite heavy) so you can include the absolutely positioned <img /> at the very end of your HTML source, which means for first-time visitors to your page, the page will appear to load more quickly.
You won't need to nest the absolutely positioned <img /> inside a parent element - which means you won't need to mess around with negative positioning, CSS inheritance, hiding overflow and so on.

Positioning text underneath and position:fixed image

I've got a Boostrap website with a navbar across the top and two columns divs in a row. The first column contains an image and should always stay fixed in position. The second column contains (potentially) a page or two of text and should scroll independently.
I've used position:fixed to hold the image in position, but my issue is that I would then like to add a link underneath it that links to the terms and conditions for the page.
BootPly
Is this possible?
Many thanks.
There a couple ways of doing this. I won't go into code since you don't have anything to work off of so I hope you can understand my explanations.
You can try simply putting the link position: fixed as well and set the top property of the link element so that it'll be positioned below your image (you can play around with this).
Use a div that is set to position: fixed that will contain both the image and the link. Then you can just simple put the image inside the div without any positioning and the link should go underneath the image without any positioning either.
You can set the text on the right side to be overflow: scroll and set the width/height of the right text in the div so that it can scroll. This will essentially keep the document still but allows the user to scroll up and down the text content inside the right side div.
Number 1 is the quickest solution, number 2 IMO is the best solution. If you need some help with the code, post a Fiddle so we can see what you're working with.
Try this:
DEMO
<div style="position:fixed">
<img src="http://placehold.it/100x300" class="img-responsive">
Terms and Conditions - Privacy Policy
</div>