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

29.10.11

PHP Web Design 101

The Most Powerful Way to Build Your Website



Elementary explanation of basic HTMLPHP website structure:
First defining DOCTYPES and META data then

Main 3 parts of every page:
HEADER header.php
FOOTER footer.php
SIDEBAR sidebar.php

connect together pages with main content
via php statement
PHP INCLUDE:

in at least one required
INDEX PAGE index.php

may add other pages of content with PHP INCLUDES of 3 main parts

Also gives good basic explanation of how to use CASCADING STYLESHEET, style.css,  to format entire site.

Lots of beginners tips to fix common problems like

Use MIN-HEIGHT when sizing the elements that aren't fixed height.
Zeroing MARGINS and PADDING for body selector.
Adding AUTOFLOW to get wrapping parent divs to stretch across floating child divs.
Add 'wrapper' class with AUTO MARGINS around each div you need to CENTER

Detailed explanation of how to style UNLIMITED LIST of links into a horizontal list for navigation with
DISPLAY:INLINE
TEXT-DECORATION NONE removes bullets
OVERFLOW:HIDDEN keep color from flowing beyond nav bar boundaries.

Additional videos on http://www.johnmorrisonline.com
Enhanced by Zemanta

22.2.11

Designing Forms with CSS and Image Replacement for Buttons

***view Edit HTML for source code***

BASIC FORM CODING










Male

Female


CSS CODING FOR BG IMAGE REPLACEMENT FOR BUTTONS/INPUT FEILDS
.fieldset .textfield {
margin:3px;
height:20px;
width:200px;
/** hides input element but keeps function **/
border:solid 0 #fff;
background: transparent

/** add bg img and browser fixes **/
url("graphics/textfield_bg.gif") no-repeat fixed; }


fieldset>input.textfield {
background: transparent
url("graphics/textfield_bg.gif") no-repeat; }

------------------------------------------------------
IE5

#login input.button:hover
{

background-image:url(../images/login.png);
background-repeat: no-repeat;
height: 69px;
width: 70px;
}

-------------- http://www.rtbwizards.com/helpcenter/cssforms.htm

Warning: you cannot have both a submit button image and a reset button image. Using an image will cause the reset button to also submit the form in Internet Explorer.
From this:





To this:





http://woork.blogspot.com/2008/06/form-elements-design-using-css-and-list.html

20.2.11

Global White Space Reset

CSS Negotiation and a Sanity Saving Shortcut
http://leftjustified.net/journal/2004/10/07/css-negotiation/

Global White Space Reset
http://leftjustified.net/journal/2004/10/19/global-ws-reset/

* {
padding:0;
margin:0;
}



this rule cancels the padding and margin of every single element; something which has already been found to have the negative side affect of hiding the drop-down arrow of a select form widget in Firefox. That problem is very simple to fix, (re-apply padding to select select { min-width:1.5em; } – thanks Bryan) but it does bring up a good point — care should be taken when applying this rule to a page which contains forms as usability must remain paramount whenever styling forms.

* {
padding:0;
margin:0;
}
body {padding:5px;}
h1, h2, h3, h4, h5, h6, p, pre, blockquote, form, label, ul, ol, dl, fieldset, address { margin:20px 0; }
li, dd, blockquote { margin-left: 40px; }
fieldset { padding:10px; }


This will basically replicate the original layout of the page in Mozilla, only it will be cross-browser; no differences on lists or other troublesome elements in IE or anywhere else. That’s effective, but it’s far from exciting. What about if we replaced all the values with relative units (% or em)?


* {
padding:0;
margin:0;
}
h1, h2, h3, h4, h5, h6, p, pre, blockquote, label, ul, ol, dl, fieldset, address { margin:1em 5%; }
li, dd { margin-left:5%; }
fieldset { padding: .5em; }

Hey now, that’s a bit more like it! Now we have the basis for a site whereby all side margins are controlled by browser width and all vertical spacing is controlled by font size. Quick, simple and highly usable — this could easily be used as the basis for a solid but highly flexible fluid layout.


-------------

http://www.search-this.com/2007/03/12/no-margin-for-error/
One of the main causes for the many positional differences between layouts in various browsers is due to the default stylesheet each browser applies to give styling to certain elements. This usually involves setting default margins and padding to some elements to make them behave in a certain way.

various browsers will apply different amounts of margin to the body to give the default gap around the page. It is important to note that Opera does not use margins for the default body spacing but uses padding instead. Therefore we must always reset padding and margins to be 100% sure we are starting on an even footing.

Global White Space Reset

These days it is common to use the global reset technique which uses the universal selector (*) to reset all the padding and margins to zero in one fell swoop and save a lot of messing around with individual styles.

* {margin:0;padding:0}

Lists need a special mention here as it is not often understood that the default space or the bullet in lists is simply provided via the default stylesheet in the provision of some left margin. Usually about 16px left margin is added by default to the UL to allow the bullet image to show; otherwise there is nowhere for it to go.


If have been reset to zero, you will need to ensure that there is still enough room for the bullet to show. I usually allow 16px left margin (or padding) as a rough guide and that seems to work well. (You can use either padding or margin for the default bullet space.)

Drawbacks

First of all, certain form elements are affected by this global reset and do not behave as per their normal defaults. The input button in Mozilla will lose its "depressed when clicked effect" and will not show any action when clicked other than submitting the form, of course. IE and Opera do not suffer from this problem and it is not really a major issue but any loss of visual clues can be a detriment to accessibility.

You may think that you can simply re-instate the margin and padding to regain the depressed effect in Mozilla but alas this is not so. Once you have removed the padding then that changes the elements behavior and it cannot be restored even by adding more padding.

There is also an issue with select/option drop down lists in Mozilla and Opera. You will find that using the global reset will take away the right padding/margin on the drop down list items and that they will be flush against the drop down arrow and look a little squashed. Again, we have problems in re-instating this padding/margin in a cross browser way.

You can't add padding to the select element because Mozilla will add the padding all around which includes the little drop down arrow that now suddenly becomes detached from its position and has a big white gap around it. You can, however, add padding right to the option element instead to give you some space and this looks fine in Mozilla but unfortunately doesn't work in Opera. Opera in fact needs the padding on the select element which as we already found out messes up Mozilla.


There is no easy fix -- it's something you have to live with if you use the global reset method.


Conclusion

The global reset is useful for beginners who don't understand that they need to control everything or who simply forget that elements like forms have a great big margin in IE but none in other browsers.
Adding background images to form elements destroyed the alignment. Adjustment to padding and margins helped realign elements but the cross browser differences were drastic. esp in IE. see Global White Space Reset.

19.2.11

Nuli! Nuli! Project: Fix gap between divs with top padding

 Gap between "hints" div above "menu" div corrected by adding top padding to "menu" div.

11.9.10

Error Fix | Adjust DIV dimensions for Padding

Can't figure out why dimensions aren't working out. Check your padding! adding padding adds to the overall dimensions of your DIV. For example you have set div width to 900 to match an image width of 900px, but the DIV comes out wider. It could because your set your padding: 30 (that 30 for all sides). This means that the left and right padding = 30 each. This adds 60px to the overall width of the DIV (360px).

Resolve by removing padding or add 60 px to the DIV width to adjust for the right and left padding.

Errot Fix | Zero Padding to Rid Unwanted Space

Working on subpages for the NS project, I decided to build my own html page with divs instead of a Photoshop generated table layout. But I couldn't get rid of this unwanted top space, even after setting the margins to zero. (didn't have this problem with table layout)
Padding the body at zero solved my problem. To be on safe side by default zero your margins & padding to avoid undesirable spaces that you didn't specify. The following code sets my layout to "zero" by getting rid of any unwanted spaces brought about by the browser. Note the auto margin in the outer div also centers the layout (see previous post). Need to start every new web page with this basic code to avoid headaches!
body {
padding: 0; 
margin: 0;
background-color: #D66D29;
}
#wrapper {
padding: 0;
margin: 0 auto;
width: 1200px;
}

10.9.10

Note To Self: Centering Web Page

  1. WARNING: If exporting web page from Photoshop don't forget to take into consideration which SETTINGS to choose greatly affects your centering options.
  2. The DEFAULT - TABLE based layout - allows you to easily center the web page in DW by right clicking in the white space, the choosing "center" in the drop down menu of the "Edit Tag - Table" dialog box. (You can also add the background color by editing the background of the table.)
  3. Choosing a CUSTOM - CSS based layout - will produced nicely named DIVs but the CSS will include ABSOLUTE Positions which can't easily be centered by normal CSS methods. You will have RE-LAYOUT the slices using new CSS. A real pain for any complex layout.
  4. Now to center webpage using CSS, you must use AUTO MARGINS for a DIV that wraps the entire layout which I usually enclose in MAIN or CONTENT DIV ( "text-align: center" is the fix needed for IE ) See this example used for my designables.net web site:
/** center web page in IE6 add text_align:center;
re-align left in wrapper **/
body {
color: #CCC;
padding: 0;
text-align: center;font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
background-color: #000;
background-image: url(images/bg.gif);
background-repeat: repeat-x;
}

/*** center web page: add auto margins outermost div; 
but re-align text center to make up for IE fix  ***/
#wrapper {
width: 670px; 
text-align: left;
border: 0px; 
padding: 0;  
margin: 0 auto; 
}
Related Posts with Thumbnails