Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

2012/01/20

A few note on z-index

z-index is widely used in dropdown menu/block to make one div on the top of the other. Here are a few I learned from.

1. Z-index only works on "realtive" or "absolute" position.
2. Higher z-index layer usually on the top of lower one, but in IE7, it's not that obviously. To fix IE7's z-index problem, you need to make sure, set z-index for the same stacking layers. (See example below)

<div id="p1" style="position:relative">
   <div id="c1" style="position:relative; z-index:10">
         I want to be on the top!!!
   </div>
</div>

<div id="p2" style="position:relative; z-index:5">
   <div id="c2" style="position:relative; z-index:5">
        I can be on the bottom!!!
    </div>
</div>
In order to make the above example works in IE7, you have to set 'p1' to have z-index higher than 'p2'.
3. Don't set parent layer's overflow is hidden, that will children cannot overlay.

Good luck

2011/07/18

How to center dynamic ul

A UL is a block element, it'll take up the whole width of its container. If you remove float:left and set a width to it, then margin:0 auto will work, but only the ul will center and not the li, unless you know exactly what the width of the UL should be. If you do not know what the ul width should be(e.g. dynamic list menu), then you need to float:left the UL and li, put it in a div, and use this trick to center http://pmob.co.uk/pob/centred-float.htm

2010/08/24

Insert code

<?php
//post without border to see what happen
$tool = 'Source Code Formatter';
$auther = 'Amer Gerzic';
//all syntax highlight is using inline css
?>
I did set up border, and wanted to see if I can apply css to it, then after the template change, I only need to update css file.

2010/08/17

ie hack

As an web developer, I wish there was only one browser, then we should not worry about the crossing browser compatible issue. But on the other hand, if there was only one browser, then it would be a very bad thing for the end user. So web developers are talking about ie-hack or firefox-hack, or opera-hack. But most of developers probably like firefox more than IE, who start from Firefox, and then test, tweak and fix css problem on another browser. So do I.

If don’t want to write a separate css file for IE using conditional comments, then you might use a simple character hack.

2009/02/24

Fixed postion in IE6

To have something always shown on the same position on a page, we can use css position property and set it to "fixed", however it doesnot work in IE6. There might be some hack to make this happen in IE6, actually I searched along trying to find one, but have not find a good solution yet. Anyway I am not going to spend time on the IE hack, what I going to do is just hidded this funtion in IE6. Complaint? Who care! Why not just leave that old buggy stupid IE6, you have a lot of option, have not you?
So the html code is like this:
<div id="footerud">
<div id="up"></div>
<div id="down"></div>
</div>
The css is that:
#footerud{bottom:10px;display:block !important;position:fixed;left:15px;}
#up{
background:url(../images/arrowtop.png) no-repeat;
cursor:pointer;
height:14px;
margin-bottom:15px;
position:relative;
width:25px;
}
#down{
background:url(../images/arrowbottom.png) no-repeat;
cursor:pointer;
height:60px;
margin-top:15px;
position:relative;
width:25px;
}  
To hidded this on IE6, I added style into html code, like
<div id="footerud" style="display:none;">
 
Will that hidded it from Firefox or IE7? Don't worry, because we have this in the css file,
#footerud{bottom:10px;display:block !important;position:fixed;left:15px;}
The !important generally means the attribute cannot be overwrote, fortunately, IE6 does not recognized it, so it will be hid.