I have this html
<div class="p-box">
<div class="p-img"></div>
<h3>title</h3>
<div class="txt">some txt</div>
</div>
with this css.
.p-box {
width:253px;
height:155px;
position:relative;
float:left;
overflow:hidden;
background: url(../images/p-box-bg.png) top left no-repeat;
}
.p-box h3 {
color:#FFF;
width:253px;
text-align:center;
font-size:12px;
height:22px;
line-height:22px;
display:block;
}
.p-img {
position:absolute;
top:1px;
left:1px;
width:253px;
height:155px;
z-index:5;
background: url(../images/p-img-bg.png) top left no-repeat;
}
.p-box .txt{
width:249px;
height:20px;
background: url(../images/p-img-txt-bg.png) top left no-repeat;
position:absolute;
bottom:2px;
left:2px;
z-index:50;
text-align:right;
color:#FFF;
font-size:12px;
line-height:20px;
}
In firefix all ok, but in IE i can't see my H3 over the p-img and p-img don't feel the container overflow..
can anyone help me??
Thx.
I would recommend on your H3, set it to something more particular, ie: an id. Once done, set the background image in the new id tag, not the H3 element in css. so:
.p-box #h3image {
color:#FFF;
text-align:center;
font-size:12px;
display:block;
enter code here
width:253px;
height:22px;
padding-top: 133px;
z-index:5;
background: url(../images/p-img-bg.png) top left no-repeat;
}
Note that the padding-top 133 px + height of 22px will make the entire height of the container 155px; being the size of your image. As the padding from the top is 133, this will leave 22px for the text to be in place, as the image is a background, text is in the foreground, fully seo compliant and browser compatible.
:)
As some articles allude with on IE's z-index bug, give the h3 element a high z-index (at least, higher than the z-index=5 given to .p-img).
Related
I'm having an issue with images overflowing the set border for link type posts on my tumblr blog. I've tried re sizing width and height ratios and percentages for images, and yet I haven't been able to fix the issue. This also isn't an issue for images on of any other post types.
Here is the code that I'm pretty sure dictates the appearance of this.
.post.link .postcontainer{
padding:0;
overflow:hidden;
padding-bottom:5px;
}
.post.link .description{
padding-left:20px;
padding-right:60px;
padding-bottom:10px;
}
.post.link a.postlink{
font-family:"Helvetica Neue", helvetica, Arial, sans-serif;
font-size:12;
color:#000;
font-weight:bold;
width:428px;
padding-right:70px;
display:block;
padding-top:15px;
padding-bottom:10px;
padding-left:20px;
text-decoration:none;
}
.post.link a.postlink span{
background: url(http://static.tumblr.com/xsp9wak/PHAkloide/icon-linkpost-arrow.png) no-repeat top left;
width:35px;
height:36px;
display:block;
position:absolute;
right:20px;
top:50%;
margin-top:-17px;
opacity: .7;
-moz-opacity: 0.7;
}
.post.link a.postlink:hover span{
opacity: 1;
-moz-opacity: 1;
}
.post.link .vialink{
margin-left:20px;
}
For images, its ideally to add the following CSS rule:
img {
max-width: 100%;
}
When you set width to 100% it takes the width of content box. It will be fine when you don't have any padding or border. But, when you add border, then the width of border will be added to the 100% and it will be more than 100% which causes the overflow. So to include the border within the 100% you should set box-sizing property in css of image.
box-sizing: border-box;
I am trying to get some hardcoded text to show above a absolutely positioned element that is an image using z-index to no avail.
Is there something I'm missing?
.repay {
font-family:Arial,Helvetica, sans-serif;
font-size:18px;
color:#444;
text-align:center;
font-weight:bold;
margin:40px 0px 30px 0px;
z-index:10001;
}
.sliderbubble-repay {
width:227px;
height:140px;
background:url('../images/white-sliderbubble.png') no-repeat;
position:absolute;
top:119px;
left:255px;
z-index:1;
}
Elements need to have position:absolute; or position:relative; for z-index to work.
Try adding position:relative; to .repay
HTML
<div id='divTop'>divTop<br>divTop<br>divtop</div>
<div id='btnHome'>Home</div>
<div id="player">player<br>player<br>player</div>
CSS
body{
position:relative;
max-width:1024px;
height:100%;
margin:0 auto;
font-family: "Trebuchet MS", sans-serif;
text-align:center;
}
#divTop{
display:none;
position:relative;
z-index:5;
text-align:center;
background:#008080;
border-bottom:medium ridge #D10000;
}
#btnHome{
cursor:pointer;
position:absolute;
top:1.5vh;
left:1vw;
max-width:3.4vw;
z-index:6;
}
#player{
display:none;
position:relative;
z-index:3;
max-width:95vmin;
max-height:95vmin;
border:medium ridge #ffffff;
border-radius:9px;
}
JS
y = $(window).innerHeight() - $('#player').height();
$('#player').css ('margin-top', y/2);
$('#player').show();
$("#btnHome").click(function() {
$('#divTop').slideToggle('slow');
});
Why is btnHome inside player. It should be fixed on top-left of page ?
Clicking on btnHome why is player pushed down ? It should be also fixed. I just want to show-hide divTop by overlapping everything bellow.
fiddle is here
Remove position:relative from body.
UPDATE: add a parent wrapper to the #divTop
#wrapper {
width:100%;
overflow:hidden;
}
#divTop{
position:relative;
z-index:5;
text-align:center;
background:#008080;
border-bottom:medium ridge #D10000;
}
JS
var dTHei = $('#divTop').outerHeight(); //get height of the #div top
$('#wrapper').height(dTHei); //set it as the height of the wrapper
$('#divTop').hide(); // hide the div top
//run your function here
http://jsfiddle.net/2zAm5/1/
Try changing position from relative to absolute
and use top,bottom,right and left instead.
change positions of btnHome and player to fixed, and also use top property for player so it will not move: e.g. top : 200px.
#divTop{
display:none;
position:relative;
z-index:5;
text-align:center;
background:#008080;
border-bottom:medium ridge #D10000;
}
#btnHome{
cursor:pointer;
position:fixed;
top:1.5vh;
left:1vw;
max-width:3.4vw;
z-index:6;
}
#player{
display:none;
position:fixed;
z-index:3;
max-width:95vmin;
max-height:95vmin;
border:medium ridge #ffffff;
border-radius:9px;
top:200px;
}
I have a cicle created with CSS that is positioned absolutely in it's container. The text in the circle is a link. Can this link be centered vertically and horizontally inside the circle? I am testing on Firefox and Chrome with the browser set to 320px wide. I am also testing on the iOS Safari Mobile.
Here is a fiddle I made to demonstrate where I am at with this at the moment:
http://jsfiddle.net/rFZBA/
Here is the HTML:
<div class="container">
<div class="circle">
+
</div>
</div>
Here is the CSS:
.container {
position:relative;
width:300px;
height:100px;
background-color:#999;
}
.circle {
position:absolute;
left:100px;
top:50px;
height:1.25em;/** 20px / 16px = 1.25em **/
width:1.25em;/** 20px / 16px = 1.25em **/
padding:0.75em; /** 12px / 16px = 0.75em **/
border-radius:1.375em; /* Half of 44px is 22px :: 22px / 16px = 1.375em **/
background-color:#4d90fe;
color:#FFF;
box-shadow:1px 1px 2px 2px rgba(0, 0, 0, 0.4);
text-align:center;
}
.circle > a {
color:#FFF;
text-decoration:none;
font-size:2.5em;
font-weight:bold;
}
Simply apply the .circle to the <a> tag: http://jsfiddle.net/rFZBA/16/
And then do some little modifications so that the size is good.
It's automatically centered here as the border is around the text and the text is of quadratic size (a single +). Also, don't forget to make the line-height equal to the height and with, so that's centered vertically.
use line-height and text-align
.circle > a {
color:#FFF;
text-decoration:none;
font-size:2.5em;
font-weight:bold;
line-height:0.625em /* wich is 1.25em (2.5/5X1.25) or use : 1.25rem; */;
text-align:center;
}
Did you try something like this?
http://jsfiddle.net/rFZBA/10/
.circle > a {
color:#FFF;
text-decoration:none;
font-size:2.5em;
font-weight:bold;
display:block;
position:absolute;
left:10.5px;
top:0px;
}
I was able to get it centered by adding display: table; to .circle and display: table-cell; vertical-align: middle; to .circle a; however, it created an oblong object rather than a pure circle. Here's the fiddle. http://jsfiddle.net/Nirvanachain/rFZBA/
If I change the font size of the <a> to 16px, then you have exactly what you want.
I create Any div in auto width with single image background. in act this worked but There is a small problem. end of right images not overlapped.
HTML :
<div class="home"><span><em>40</em></span></div>
CSS :
.home{
border:none;
background:none;
padding:0;
margin:0;
width:auto;
overflow:visible;
text-align:center;
white-space:nowrap;
height:40px;
line-height:34px; display:inline-block;
}
.home span, .home em{
display:inline-block;
height:40px;
line-height:34px;
margin:0;
color:#954b05;
}
.home span{
padding-left:15px;
background:url(http://www.uploadup.com/di-GRW2.png) no-repeat 0 0;
}
.home em{
font-style:normal;
padding-right:20px;
background:url(http://www.uploadup.com/di-GRW2.png) no-repeat 100% 0;}
See E.X In Action : HERE
My Problem : HERE
It's doing that because the corners of your PNG are transparent. Either make them white (same as background) or use another method. Most modern browsers allow you to do rounded borders via CSS now (with the exception of IE).
you can make the same curve box as per your image with css3 here is small css for you to make curve box and compatible with all browsers:-
.box {
border:1px solid #dadada;
width:50px;
height:50px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
behavior: url(border-radius.htc);
}
check the live demo:- http://jsfiddle.net/ZysQa/3/
i have used behavior hack for ie support border radius property so for ie border details you can read this article.....cross browsers css3 border radius