crossz

Archive for the ‘css’ Category

HOWTO: outer DIV can not cover element with FLOAT style

In bug, css, howto on March 31, 2009 at 12:03 am
Normally, all the content in the outer DIV will inherit the css styles from it, such as background.
But when the float style is used for inner tag, this part of content may come out of the outer DIV. Also, if you are using Firebug in Firefox, when your mouse is hovering on the outer DIV, the browser then will not cover all the parts inside the DIV.

All are because the FLOAT style.

In this article, Simple Clearing of Floats, 4 methods are intorduced to fix this ‘bug’, which appears in Firefox, Chrome, while not in IE, this did supprise me. Normally IE is more buggy in my opinion.

My favorite method is to append the outer style with ‘overflow:auto’. Then, the floated part will be covered by the outer DIV, no matter the background issue or the selection problem in Firebug.

See also: (other conflicts with some attributes)
text-align for normal div tag ( this will not work 100% in table with align attribute, this will be ignored) and align attribute for table: here


style of marquee in div ( style of div will not work 100%)

40 Beautiful PSD Slicing Websites

In css on March 29, 2009 at 11:41 am
From: http://designmovesme.com/40-beautiful-slicing-websites/

March 27, 2009

Correctly slicing a PSD into XHTML & CSS is an art that takes time to master. If development and coding is not your thing, there are companies that will take your web design file and bring it to life. There are several factors to consider when choosing a PSD slicing company, and one of them is the design of their own site. If their design appears to be low quality, what is their code going to be like? In this article, I’ve listed 40 PSD slicing companies with beautifully designed sites.

40 Beautiful PSD Slicing Websites

Nifty XHTML

PSD to HTML

MediaGirl

Markup4U

markmeup

HTML Burger

Feather Code

The Designer’s Chop Shop

CSS Rockstars

CSS Ninjas

CMSthemer

The Choppr

247xhtml

9xhtml

YummyCSS

XHTML Team

XHTML Slicer

XHTML Slice

xHTML Master

XHTMLized

XHTMLiT

WPfromPSD

WPCoder

We Do Markup

W3 Markup

ThemeSlice

SnobbySlice

Slice’r’us

Slice&Go

RetroXHTML

QualityXHTML

PSD to WordPress

psdtolife

PSD to Any

PsdSlicing

Psdslicer

PSDgator

PSD2HTML

PixelCrayons

Outline to Design

Javascipt onload confclits

In JavaScript, css, joomla on March 24, 2009 at 10:54 am
Normally there are two ways to run javascipt when html page is loaded:

  1. window.onload=INLINE_FUNCTION_NAME, is normally used to make specific javascript runnable when the html document is loaded.
  2. general javascript function, like “function FUNCTION_NAME() {… }; FUNCTION_NAME();”

The problem of method 1) is that one page only can have one onload function. there are always conflicts in Joomla or drupal which use a lot of javascript for functions.

The problem of method 2) is that when the function started, maybe the html document is not fully loaded.

FIX
===============================
To solve this, ‘domready’ from mootools helps a lot and improves the loading speed very much. See domready vs load.
Insert mootool.js (optional for Joomla, But required for local html test)
—————————————————
<script type="text/javascript" src="mootools.js">
</script>

—————————————————
You should go to mootools.net to download the latest mootools.js.

HOWTO: Joomla CSS drop-down menu (javascript for IE6)

In css, howto, joomla on March 23, 2009 at 7:58 pm
Prolog
===================

At beginning, I compared the two drop-down menu raw methods:
http://docs.joomla.org/Creating_a_CSS_Drop_down_Menu
http://www.alistapart.com/articles/dropdowns

Both of them are using suckerfish CSS methods to diminish javascript usage from DHTML.
Because IE doesn’t support ‘hover’ status on ‘li’, only on ‘a’. to solve this problem, there is some javascript for IE, using ‘onmouseover’.

The difference between the above two javascript methods, one uses 1)’document.THECLASSOFTAG.getElementsByTagName(“LI”)’ to retrieve <li>, while 2) the other uses ‘navRoot.childNodes……’ with loop to find out all <li> within the range, which defined by ‘document.getElementById(“THEIDOFTAG”)’.

Javascript in method 1) is NOT supported by IE 6 and 7, even Firefox. This only affect IE 6, others don’t need javascript to achieve this drop-down menu.

But, the ‘hiding method’, which uses ‘left:-98%’ to hide the submenu from screen is very good and secure, compared with the method using ‘display: none’, which used in method 2).

Method 2) is just traditional way to parse the html document. But it’s for pure HTML practice, not exactly for Joomla.

Therefore, I modified above 2 methods, to make it easily setup on Joomla 1.5.

Make Joomla Drop-Down Menu without install anything
===================================

1. Create your Menu with the following Hierarchy:

Menu 1( globalnews ).

– Menu 1 Sub Menu 1 (test).

– Menu 1 Sub Menu 2 (test).

Menu 2( uknews ). // this menu have no submenu

2. Make sure the parameters are set to.

• Menu Style is set to List.

• Always show sub-menu Items is set to Yes.

• Menu Class Suffix is set to -nav – you can pick you own, but then make sure you change it in CSS & JS files. So you will get your menu within

All the menu strcture will be like this ( this can be found from your scource from IE or Firefox:
————————————————-

<div class="pill_m">
<div id="pillmenu">
<ul class="menu-nav">
<li class="parent item63"><a href="/globalnews"><span>Globalnews</span></a>
<ul>
<li class="item75"><a href="/uknews"><span>test</span></a></li>
<li class="item76"><a href="/uknews"><span>testtest</span></a></li>
</ul>
</li>

<li class="item61"><a href="/uknews"><span>uknews</span></a></li>

</ul>
</div>
</div>

—————————————
here, the ‘div class=”pill_m”‘ and ‘div id=”pillmenu”‘ is what I put in the templates/MYTEMPLATE/index.php to help me setup the css style.

3. Insert this piece of JS in your template index.php ‘head’ tag, or in java script file that’s called from index.php.
—————————————
<!--[if IE]>
<script type="text/javascript">
window.addEvent('domready', function()
{
if (document.getElementById) {
//navRoot = document.getElementById("pillmenu");
ulTag = pillmenu.childNodes(0);//navRoot==pillmenu, which is a 'id'.
for (i=0; i<ulTag.childNodes.length; i++) {
node = ulTag.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
temp_cn=this.className;
this.className=temp_cn.replace(temp_cn, "sfhover")
//this.className+="sfhover";
}
node.onmouseout=function() {
this.className=this.className.replace("sfhover", temp_cn);
}
}
}
}
}
);
</script>
<![endif]-->
—————————————-
Note:

  • Here <!–[if IE]> make this script just work for IE, to improve the performance of Fifrefox,safari, they do need such javascript to make the dorp-down menu.
  • window.onload=INLINE_FUNCTION_NAME, is normally used to make specific javascript runnable when the html document is loaded, BUT, in joomla, there always a lot of javascript block in the pages, and one page only can have one onload function. To solve this, ‘domready’ from mootools helps a lot and improves the loading speed very much. See domready vs load.
  • Even using general javascript function, like “function FUNCTION_NAME() {… }; FUNCTION_NAME();”, will not work properly, because when the function started, maybe the html document is not fully loaded. Still, mootools domready event helps.

4. Insert mootool.js (optional for Joomla, But required for local html test)
—————————————————

<script type="text/javascript" src="mootools.js">

</script>

—————————————————
You should go to mootools.net to download the latest mootools.js.

5. Here the corresponding CSS
—————————————————-
<style type="text/css">
/*****************************************/
/*** Copied menu ***/
/*****************************************/
.pill_m {
text-align: center;
margin: 0 auto;
padding: 0;
background: url(../images/menu.jpg) top center repeat-x;
width: 100%;
height: 41px;
}
#pillmenu {
margin:0 auto;
width:960px;
}
#pillmenu ul {
margin: 0;
padding: 0 22px;
list-style: none;
}
#pillmenu li {
float: left;
margin: 0;
padding: 0;
height: 49px;
background: url(../images/menu_li.jpg) top right no-repeat;
}
#pillmenu li:hover {
}
#pillmenu li a#active_menu-nav {
}
#pillmenu li a {
font-family: Verdana,Helvetica,Arial,sans-serif;
font-size: 13px;
/* float: left;*/
display: block;
line-height: 39px;
padding: 0 24px 0 16px;
color: #111111;/*color: #FFFFFF;*/
text-decoration: none;
font-weight: bold;
text-transform:uppercase;
}
#pillmenu li a:hover {
color: #CCCCCC;
}
.pill_m li ul { /* second-level lists */
position: absolute;
left: -98%; /* using left instead of display to hide menus because display: none isn’t read by screen readers */
}
.pill_m li:hover ul, .pill_m li.sfhover ul { /* lists nested under hovered list items */
left: auto; /* change is to 10px, 20px, etc for indenting the sub menue */
z-index: 100;
}
#pillmenu li.parent ul li, #pillmenu li.sfhover ul li{
height:20px;
background: url(../images/menu.jpg) top center repeat-x;
}
#pillmenu li.parent ul li a, #pillmenu li.sfhover ul li a{
font-size: 10px;
line-height: 20px;
}
</style>
—————————————————-
Here the background can be changed as you want, or set it ‘none’ or other colors.
Have a try, If you got any problems, comment here to let me know.

IE CSS: texts display incompletely

In bug, css on March 16, 2009 at 6:58 pm
Some texts, huge ones, bigger than 20px, especially link (<a>), will not display completely in IE. Always missing the top part of the characters.

Why?
===========
1) This just happens when the texts are embedded in ‘table’, while no problem with ‘div’.

2) Not the problem of the height of ‘tr’. No matter how you change it, it will not fix it.

3) The real reason is the ‘line-height’, which normally declared in ‘body’ part.

Fix:
===========
in the specific table, to use class or ID to select the table you want to modify, add ‘line-height’, make it 10%-15% bigger than that declared in body part.

This variable is just like the line space we always use in OFFICE WORD, normally I set it to 1.5, to make it look comfortable.