Position absolute and z-index in IE10 - html

Bit of a strange one, I'm trying to overlay a couple of links over an image, and only in IE (all versions) is it displaying them behind the image. Works in Chrome, Firefox, et al.
I've tried giving each element an appropriate z-index but it doesn't actually make any difference.
I swear I've done this a a million times before with issues.
Here's a JSFiddle for it:
http://jsfiddle.net/SY8xp/
<span>Link 1</span>
<span>Link 2</span>
<img src="http://lorempixel.com/212/43" width="212" height="43" alt="" id="logo" />
.logo-link-a span, .logo-link-b span {
display: none;
}
.logo-link-a {
display: block;
position: absolute;
width: 50px;
height: 50px;
margin: 25px 0px 0px 0px;
}
.logo-link-b {
display: block;
position: absolute;
width: 165px;
height: 50px;
margin: 25px 0px 0px 50px;
}
#logo {
margin-top: 30px;
}

A hackish solution is to add a background-color to the <a /> elements. Adding this to your jsfiddle's CSS worked:
.logo-link-a, logo-link-b {
background-color: rgba(255,255,255,0);
}

what's the reason to hide links over an image? you can wrap the image with <a> tag and create the link without much markup, you can also use image replacement that brings good results for the SEO of page also
here some tricks to image replacement: http://css-tricks.com/css-image-replacement/
here a fiddle: http://jsfiddle.net/9V5g8/1/
HTML:
<!-- option 1 -->
<img src="http://www.starbucks.com/static/images/global/logo.png" alt="">
<!-- option 2 -->
<div class="logo">
<a href="http://www.starbucks.com/">
<h1 class="img-replace">
My Logo
</h1>
</a>
</div>
CSS:
h1.img-replace {
width: 85px;
height: 84px;
background: url("http://www.starbucks.com/static/images/global/logo.png") no-repeat 0% 50%;
text-indent: -9999px;
}

Related

How to place an image on top of text?

the top attribute appears not to be working on a html. I am trying to use the top attribute on image to move an image to the top and place above a text but the top attribute of a css never moves the image Here is snippet
<div class="stl_02">
<div class="stl_03">
<img src=""
alt=""style="top: 4.4538em;" class="stl_04">
</div>
<div class="stl_view">
<div class="stl_05 stl_06">
//other texts here
here are the css rules
.stl_02 {
height: 46em;
font-size: 1em;
margin: 0em;
line-height: 0.0em;
display: block;
border-style: none;
width: 51em;
}
.stl_03 {
position: relative;
}
.stl_04 {
width: 100%;
clip: rect(-0.041667em,51.04167em,66.04166em,-0.041667em);
position: absolute;
pointer-events: none;
}
Please how can push the image to the top using this attribute style="top: 4.4538em;" is a challenge
Your element does have the top attribute applied. This can be seen in the following:
.stl_02 {
height: 46em;
font-size: 1em;
margin: 0em;
line-height: 0.0em;
display: block;
border-style: none;
width: 51em;
}
.stl_03 {
position: relative;
}
.stl_04 {
width: 100%;
clip: rect(-0.041667em, 51.04167em, 66.04166em, -0.041667em);
position: absolute;
pointer-events: none;
}
<div class="stl_02">
<div class="stl_03">
<img src="http://placehold.it/100" alt="" style="top: 4.4538em;" class="stl_04">
</div>
<div class="stl_view">
<div class="stl_05 stl_06">
</div>
</div>
</div>
If you are not seeing this effect, it is possible you have a rule with higher specificity overriding it, or you have cached the style before you applied this rule.
It's also worth noting that top only works on a positioned element. You need to have position: relative, position: absolute or similar on .stl-04 in order to position it with top.
Alternatively, you may be looking for margin-top, which positions vertically based on the containing element.
As an aside, basing margins off of font sizes (with em units) is generally bad practice; you should really use fixed units instead (preferably not going to so many decimal places).

small image link as a button at the bottom right of the image it is selling

Im trying to put a link button to amazon on a picture but not only is it not working its making my website all wonky
.review-page-lander > img {
width: 100%;
max-width: 1169px;
margin: 0 auto;
}
img.buy-from-button{
height: 35px;
width: 150px;
top: 35px;
float:left;
position: relative;
z-index: 1;
}
<div class="lander-image">
<a href="#">
<img class="buy-from-button" src="http://oathtohealth.com/wp-content/uploads/2016/05/Amazon.png" alt="buy at amazon">
</a>
<img src="amazon-item.jpg">
</div>
As i mentioned in my comment, difficult to answer without more info
First off, using .review-page-lander > img wont work as the > means immediate child, http://www.w3schools.com/cssref/css_selectors.asp
To find what else not working, use F12+inspect in chrome (or similar in other browsers) to find what css being applied
https://developers.google.com/web/tools/chrome-devtools/
https://developers.google.com/web/tools/chrome-devtools/inspect-styles/
I would suggest to keep your product image above your buy button and make buy button float right relatively with bottom: 40px;
.lander-image>img {
width: 100%;
max-width: 1169px;
margin: 0 auto;
}
img.buy-from-button {
height: 35px;
width: 150px;
float: right;
position: relative;
z-index: 1;
bottom: 40px;
}
<div class="lander-image">
<img src="http://placehold.it/250x300">
<a href="#">
<img class="buy-from-button" src="http://oathtohealth.com/wp-content/uploads/2016/05/Amazon.png" alt="buy at amazon">
</a>
</div>

Making logo div a clickable link

I've got a logo and a second elements that are contained in divs sitting in the nav that I want to make links. Tried what seems like everything. It looks like the .logo svg div is linking but is running the full width of #topnav and the area with .logo is not clickable. The .nav container about div is not linking at all and I can't seem to get it to right align in the nav.
There are probable a few issues here (apologize for that) but any suggestions at all would be most appreciated.
HTML
<div id="topbar">
<a href="##">
<div class="logo svg">
<object class="logo" type="image/svg+xml" data="img/gf_logo_main.svg">
</object>
</div>
</a>
<a href="###">
<div class="nav container about">
<object class="nav about" type="image/svg+xml" data="img/question mark.svg">
</object>
</div>
</a>
</div>
CSS
#topbar {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
z-index: 1;
width: 100%;
height: 65px;
padding: 10px;
background: rgba(255, 255, 255, 0.8);
color: #000;
}
.logo svg {
float: left;
width: 50px;
}
.logo {
height: 80%;
}
.logo img {
border: 0;
display: none;
height: 100%;
width: 100%;
}
.nav container about {
position: absolute
right: 0px;
}
.nav link about{
height: 80%;
}
Page is here:
http://www.glitteringfacade.com
You don't need to use <object> tags for SVG any more. Since IE9, you can just inline it as a normal <img> (but be sure to specify its width and height, either as attributes or in CSS).
<img src="img/gf_logo_main.svg">
You can make it a "link" using onclick="window.location = 'http://www.yoururl.com';" in your div tag and giving it the cursor: pointer; CSS style.

Only text in link box is clickable

On a webpage I've got a list of thumbnails with link boxes on top of them. The are wrapped by a link tag and are clickable. However, in the link boxes on top of them which has a slightly transparent background it is only the text and not the entire box which is clickable.
This is the HTML code for one set of thumbnail and link box:
<article class="recent-post-item">
<h2>
Something
</h2>
<a href="link/to/somewhere" title="Something" class="thumb">
<img src="someimage.png" alt="Something" width="248" height="125" />
</a>
</article>
And this is the corresponding stylesheet:
#column-2 .recent-post-item {
height: 127px;
width: 250px;
position: relative;
border: none;
}
#column-2 .thumb {
margin: 0;
position: absolute;
top: 0px;
left: 0px;
}
#column-2 h2 {
font-size: 22px;
background-color:rgba(255,255,255,0.6);
padding: 5px 4px;
margin: 0;
position: absolute;
z-index: 1;
bottom: 1px;
left: 1px;
right: 1px;
}
And heres a working site showing the problem: http://fuckthepony.dk/wordpress/ (the thumbnails I'm talking about are those in the middle column)
Some people have told me that they do not experience the problem. I've tested on Linux with both Opera, Chrome and Firefox and the problem is persistent across all of these browsers.
I concur with the comments above but to make the whole transparent block clickable you would need to also take the padding off of the h2 and add the padding to the a tag instead.
#column-2 h2 {
padding: 0;
}
#column-2 h2 a {
display: block;
padding: 5px 4px;
}
This is because a elements are inline elements, so they don't take all parent's width available. You can add this rule to your css:
#column-2 h2 a {
display: block;
}
That's just because the a element has not display:block by default.
Just add this little line :
#column-2 h2 a { display:block; }

How do I put an image on top of an image without using absolute positioning?

Basically, I have some nice navigation button .png's given to me from a friend and a header/banner.jpg. I want to put these .png's on top of the .jpg banner. The problem is that I'm using a css rollover function (for the navigation buttons) that requires me to use position: relative for the divs that contain the individual navigation buttons. Otherwise the rollover function gets hairy in Opera. How would I be able to accomplish this?
Here's some code for the css (for the navigation buttons):
.cssnavabout { background: url(navigation/about_on_over.png) no-repeat; white-space: nowrap; display: block; height: auto; width: auto; float: left; position:absolute; top: 55%; left: 50% }
.cssnavabout a { display: block; color: #000000; width: auto; height: auto; display: block; float: left; color: black; text-decoration: none; }
.cssnavabout img { width: auto; height: auto; display: inline; margin: 0px; border-style:none }
.cssnavabout a:hover img { visibility:hidden }
And the HTML partition (for the navigation buttons):
<div id="csswrapper">
<div class="cssnavabout">
<img src="navigation/about_on.png" width=100 height=50 />
</div>
Heres the CSS for the header/banner:
#header { width: 1024px; height: 109px; position: relative; margin:0px; background-color:#FFFFFF; }
And the HTML for the banner:
<div id="header">
<img src="images/banner_about.jpg" width="100%" height="109" /> </div>
I'm sure this is easily solvable. Sorry, this is my first website.
How do I put an image on top of an image without using absolute positioning?
Like so...
<div style="background: url(image.png) no-repeat">
<img src="image2.png" alt="" />
</div>
Seems to be a case of z-index: http://www.w3schools.com/Css/pr_pos_z-index.asp
But you can give absolute position to the anchor that contains the png button which should do the trick.
#csswrapper a{
position:absolute;
top:20px; //edit
right:20px; //as needed
}