Text over an image in Internet Explorer - html

I currently have a problem with my z-index with IE.
I have a div, an image in this div and some text over this image.
Here is my HTML code:
<section id="content_right">
<div class="mini_bloc_image">
<img alt="Camionnette VCI" src="img/mini_reparation_site_nb.png" />
<span>Réparation sur site</span>
<span>Nous nous déplaçons</span>
</div>
and the CSS:
#content_right {
width: 230px;
height: 484px;
float: right;
}
.mini_bloc_image {
height: 148px;
margin-bottom: 20px;
position: relative;
}
.mini_bloc_image > img {
position: absolute;
}
.mini_bloc_image > span:first-of-type {
display: block;
position: absolute;
top: 95px;
left: 0px;
font-size: 1.1em;
background-color: #ffffff;
padding: 4px 5px 4px 5px;
}
.mini_bloc_image > span:last-of-type {
display: block;
top: 95px;
left: 0px;
position: absolute;
left: 50px;
top: 125px;
color: #ffffff;
font-size: 1.1em;
font-family: 'Marck Script', cursive;
}
IE don't understand my text must be OVER the image...
I found some solutions like this http://www.adrenatie.com/z-index-et-ie6/ or this http://systembash.com/content/css-z-index-internet-explorer/ but it don't works.
Can someone help me please?

Problem is you're dealing with spans, which are rendered inline by default. If you use display:block, the z-index will be used:
.mini_bloc_image > span:first-of-type {
display: block;
position: absolute;
z-index: 10;
font-size: 1.1em;
background-color: #ffffff;
padding: 4px 5px 4px 5px;
margin-top: 95px;
}
.mini_bloc_image > span:last-of-type {
display: block;
position: absolute;
z-index: 10;
color: #ffffff;
font-size: 1.1em;
font-family: 'Marck Script', cursive;
margin-left: 30%;
margin-top: 125px;
}
For more about inline elements and positioning, see this article.

Related

Div position pusing content

I am having trouble aligning my div so it doesn't push content below down, somehow if the asset name is more than one row, it will push down the metadata description down one row, I have tried positioning and flow and it seems now working, could some one please take a look to see what I have done wrong?
CSS
.port-container {
width: 490px;
height: 166px;
margin: 0px 0px 20px 0px;
float: left;
}
.port-container .port-image-link {
position: relative;
left: 10px;
}
.port-container .port-metadata-text {
padding: 50px 12px 10px 50px;
font-family: Arial, Helvetica, sans-serif;
color: #000;
font-size: 12px;
position: absolute;
margin-top: -180px;
margin-left: 173px;
z-index: 8;
line-height: 17px;
}
.port-container .port-image-link .port-text-link {
cursor: pointer;
width: 220px;
top: 138px;
position: relative;
text-decoration: none;
z-index: 9;
}
.port-container .port-image-link a {
text-decoration: none;
}
.port-container .port-image-link a span.port-text-link {
color: #fff;
font-family: Arial, Helvetica, sans-serif;
line-height: 17px;
position: relative;
top: -170px;
font-size: 12px;
text-decoration: none;
padding: 9px 50px 0px 0px;
font-weight: bold;
cursor: pointer;
left: 220px;
display: block;
}
.port-container .port-image-link a:hover span.port-text-link {
cursor: pointer;
text-decoration: underline;
}
HTML
<div class="port-container">
<div class="port-image-link">
%asset_thumbnail%<span class="port-text-link">%asset_name%</span>
<div class="port-metadata-text">%asset_metadata_DC.Description%</div>
</div>
</div>

Text over image, without affecting other texts on image

I have an image where 3 words are on, but I can't get the 3rd on it because it will not go in the position I want it. Here's the picture with words.
#clubname {
position: absolute;
margin-left: 26%;
color: #FFF;
line-height: 0px;
font-family: 'Knul-Bold';
}
#pacoins {
position: relative;
line-height: 84px;
margin-left: 13%;
max-width:5%;
max-height:5%;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
}
#myclub {
position: relative;
margin-left: 30%;
line-height: 0px;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
color: black;
}
<img src="http://packsimulator.nl/img/PAClubCover.png" style="position:absolute;">
<p id="clubname">Julan FC</p>
<p id="pacoins">97.000</p>
<p id="myclub">My Club</p>
As you can see 'My Club' isn't after the blue icon. Where it should be.
wrap these with a container/wrap div then use position:relative/absolute
.wrap {
position: relative;
width:400px /* width of image */
}
img {
position: absolute
}
p {
position: absolute;
color: #FFF;
line-height: 0;
font-family: 'Knul-Bold';
z-index: 1;
font-size: 17px
}
#clubname {
left: 40%;
}
#pacoins{
left: 25%;
top:22px;
}
#myclub {
left: 55%;
top:22px;
}
<div class="wrap">
<img src="http://packsimulator.nl/img/PAClubCover.png" />
<a href="#profile">
<p id="clubname">Julan FC</p>
</a>
<a href="#pacoins">
<p id="pacoins">97.000</p>
</a>
<a href="#club">
<p id="myclub">My Club</p>
</a>
</div>
You have to use float:left;.
Change your css to be like this
#pacoins {
position: relative;
line-height: 48px;
margin-left: 20%;
max-width: 5%;
max-height: 5%;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
float:left;
}
#myclub {
position: relative;
margin-left: 42%;
line-height: 84px;
font-family: 'Knul-Bold';
font-size: 17px;
color: black;
}
Working JSFiddle here https://jsfiddle.net/dotcgtuc/1/
Hope this helps.
You will need to position it with position: absolute;. For example
#clubname {
position: absolute;
margin-left: 26%;
color: #FFF;
line-height: 0px;
font-family: 'Knul-Bold';
}
#pacoins {
position: relative;
line-height: 84px;
margin-left: 13%;
max-width:5%;
max-height:5%;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
}
#myclub {
position: absolute;
left: 40%;
top: 45px;
line-height: 0px;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
color: black;
}
<img src="http://packsimulator.nl/img/PAClubCover.png" style="position:absolute;">
<p id="clubname">Julan FC</p>
<p id="pacoins">97.000</p>
<p id="myclub">My Club</p>
OK, you have a couple things going on here that aren't quite recommended, but with reworking your html & css I believe I've produced the result you're looking for.
First, you're embedding paragraph tags <p> in anchor tags <a> - this is only HTML5 compatible because the p is a block element while anchor is inline. I'd suggest using span tags how you have it.
Secondly, your CSS uses percentages to place these elements - so once a browser resize takes place, your elements will all be thrown off. Putting this information together, I believe we can achieve the results you are looking for:
CSS
#clubname {
position: absolute;
top: 15px;
left: 255px;
color: #FFF;
font-family: 'Knul-Bold';
}
#pacoins {
position: relative;
top: 30px;
left: 100px;
max-width:5%;
max-height:5%;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
}
#myclub {
position: relative;
left: 200px;
top: 32px;
color: #FFF;
font-family: 'Knul-Bold';
font-size: 17px;
color: white;
}
HTML
<img src="http://packsimulator.nl/img/PAClubCover.png" style="position:absolute;">
<span id="clubname">Julan FC</span>
<span id="pacoins">97.000</span>
<span id="myclub">My Club</span>
Fiddle

Css after the text going out of the box

I have a wired problem, i have a regular nav with ul and li and i am trying to make after one of the li red box with number inside, but the problem is that the number from some reason going out of the box, what is the problem?
This is the code:
#mainHeader .rightNav {
float: right;
li {
position: relative;
}
img {
vertical-align: middle;
}
li:nth-child(4)::after {
content:attr(data-value);
color:#fff;
border-radius: 2px;
background-color: #d94a3e;
text-align: center;
width: 18px;
height: 18px;
position: absolute;
top:0;
right:0;
}
}
http://plnkr.co/edit/ys7Wy3EJPlA4VlXDt6hE?p=preview
There was wrong on your line height.
Should have : line-height: normal;
Add that to #mainHeader .rightNav li:nth-child(4)::after
Update your css to this:
#mainHeader .rightNav li:nth-child(4)::after {
content: attr(data-value);
color: #fff;
border-radius: 2px;
background-color: #d94a3e;
text-align: center;
width: 18px;
height: 18px;
position: absolute;
top: 0;
right: 0;
line-height: normal;
}
Sample link
Replace your styles with this:)
#mainHeader .rightNav li:nth-child(4)::after {
content: attr(data-value);
color: #fff;
border-radius: 2px;
background-color: #d94a3e;
text-align: center;
position: relative;
top: -10px;
right: 0;
padding: 1px 4px;
}

Why won't the z-index on my elements work?

I have my code set up so I have the hero image at the bottom and the overlay on top with the text and button in overlay. I also have the navigation bar with a z-index but for some reason the button for my resume in overlay isn't working.
HTML
<div id="header">
<a href="index.html"><div id="leftHeader">
<img src="assets/logo2.jpg" alt="Logo" style="width:65px;height:65px">
<h1>Amanda Farrington</h1>
</div>
<div id="nav">
<ul>
<li>About</li>
<li>Work</li>
<li>Contact</li>
<li>Notes</li>
</ul>
</div>
</div>
<div id="hero">
<div id="heroImage">
<img src="assets/trees.jpg" alt="trees" style="width:100%;height:10%">
</div>
<div id="overlay">
<h2>Amanda Farrington</h2>
<h3>Graphic Artist | Web Designer</h3>
View Resume
</div>
</div>
CSS
#header {
color: #D7DADB;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size : 15px;
text-align: left;
width: 100%;
padding-left: 3em;
position: relative;
height: 15%;
box-sizing: border-box;
padding-top: 1em;
}
#header img
{
float: left;
padding-left: 3em;
}
h1{
width: 9em;
float: left;
padding-left: 0.5em;
color: #45CCCC;
padding-bottom: 1px;
}
#nav {
width: 50%;
margin:0;
padding:0;
text-align: right;
color: red;
font-size:20px;
float: right;
padding-right: 2em;
z-index: 99;
}
#nav ul {
padding: 1px;
}
#nav li {
display: inline;
padding: 38px;
}
#nav li a {
color: #2C3E50;
text-decoration: none;
}
#nav li a:hover {
color: #45CCCC;
}
/*----------hero image styles-------------*/
#hero{
padding-top: 25em;
width: 100%;
height: 30em;
position: relative;
z-index: -1;
}
#heroImage
{
top: 9%;
width: 100%;
z-index: 1;
position: absolute;
}
#overlay{
width: 34em;
top: -15%;
margin-left: 30%;
z-index: 2;
position: relative;
clear: left;
}
h2{
width: 100%;
position: relative;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 60px;
float: center;
color: white;
opacity: 1.0;
text-shadow: 2px 2px 3px #000000;
text-align: center;
}
h3{
width: 100%;
position: relative;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 30px;
color: #e5e5e5;
opacity: 1.0;
text-shadow: 2px 3px 2px #000000;
text-align: center;
}
a.down{
z-index: 100;
font-family: 'Roboto', sans-serif;
font-weight: 400;
text-decoration: none;
color: #181b1e;
background: #45CCCC;
position: relative;
padding: 0.6em 0.2em;
font-size: 1.2em;
-webkit-border-radius: 6px;
width: 30%;
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
a.down:hover{
text-decoration: underline;
color: white;
}
Because z-index works only on elements which are NOT set asposition: static. Bear in mind that every element is set as default to position:static.
Try set to position:absolute; or relative your element.
Also all other types of positioning, like position:fixed, position:sticky.
So I've taken a look at your code and the reason your button doesn’t work is because the div with the ID of #hero (which contains the button) is below the body because it has a z-index of -1.
Set the z-index for #hero to 0 or higher and the button will work.
#hero {
padding-top: 25em;
width: 100%;
height: 30em;
position: relative;
z-index: 0;
}
Check out this JS Fiddle I've created for you:
https://jsfiddle.net/8fqwr6ca/
Edit: Oh, and I forgot to mention–since you want the image to be below, set the #hero 's z-index to 1, set #heroImage to 0, and overlay to 2. That should do the trick (if what I think you want is correct).

How to do grid of div elements?

Quick question, I need help and have no idea what to do, because I know nothing about html/css and got this as a bonus task along with other programming things.
What I have:
What I would like to have:
Here is css code
.offer-small { width: 278px; height: 209px; position: relative; margin-bottom: 25px; }
.offer-small img { width: 278px; height: 209px; }
.offer-small .mask { width: 278px; height: 209px; cursor: pointer; position: absolute; top: 0; left: 0; background: url('../images/photo-small-mask.png'); }
.offer-small .desc { display: none; font-size: 10pt; width: 258px; height: 189px; padding: 10px; position: absolute; top: 0; left: 0; background: url('../images/photo-small-black-transparent.png'); color: white; text-shadow: 1px 1px #000000}
.offer-small .desc p { font-size: 9pt; color: #f2f0e4; }
.offer-small .desc table.compare { width: 160px; height: 48px; margin: 0 auto 0 auto; background: url('../images/offer-table.png'); color: #f2f0e4; }
.offer-small .desc table td { text-align: center; padding-bottom: 10px; }
.offer-small .desc table td.small { font-size: 8pt; }
.offer-small .title { width: 258px; background: url('../images/offer-transparent.png'); padding: 2px 10px; position: absolute; top: 120px; left: 0; }
.offer-small .title strong { font-size: 9pt; color: #ffffff; }
.offer-small .title small { font-size: 8pt; color: #f2f0e4; }
.offer-small .title small strong { font-size: 8pt; color: #f2f0e4; }
.offer-small .view-offer { position: absolute; top: 160px; left: 150px; }
.view-offer { display: block; width: 120px; height: 44px; background: url('../images/button-view-offer.png'); }
.btnSendOrder { width: 260px; height: 75px; border: 0; background: url('../images/button-send-order.png'); cursor: pointer; }
.toLeft { float: left; margin-right: 25px; }
Html/smarty code:
{if $random}{foreach item=item from=$random}
<div class="offer-small">
<img src="{$smarty.const.APP_URL}/userfiles/photos/{if $item.item_photo}s_{$item.item_photo}{else}blank_small.jpg{/if}" alt="" />
<div class="desc">
<strong>{$item.item_name|truncate:30}</strong>
<p>{$item.item_short_description|truncate:120}</p>
<p align="right"></p>
</div>
<div class="title">
<strong>{$item.item_name|truncate:30}</strong><br/><small>Cena teraz: <strong>{$item.item_cost_now|money} zł</strong> zamiast <strong>{$item.item_cost_before|money} zł</strong></small><br/><br/>
<strong>OSZCZĘDZASZ <big>{$item.item_cost_before-$item.item_cost_now|money}</big> zł</strong>
</div>
</div>
{/foreach}{/if}
Tips are welcome too.
I mean I can handle making grid if someone will show me how to break this stupid list.
An easy way is to just float the divs of class .offer-small left:
.offer-small {
width: 278px;
height: 209px;
position: relative;
margin-bottom: 25px;
float:left;
}
As long as you have them all within a container element with a fixed width, they should fit next to each other nicely, wrapping to the next line automatically.