Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-07-2012, 05:01 PM   PM User | #1
jba_site
New to the CF scene

 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jba_site is an unknown quantity at this point
Question CSS Problem: 100% Width, Floating and Centered

Hi Folks,

I was hoping you could give me a hand with the following web page, and a problem I'm having with the CSS when the window is sized smaller than the content.

The web page has divs with background colors that are meant to run to 100% of the width. However, when the window's horizontal aspect is smaller than that of the content, the background stops short:

Click image for larger version

Name:	jba-screenshot.jpg
Views:	45
Size:	45.2 KB
ID:	11341

I believe this could be something to do with the left-floating inner-sections. You can see this on the live site at:

www.jamesbaldwinantiques.com/articles.php

Any ideas?

Many Thanks.
jba_site is offline   Reply With Quote
Old 07-08-2012, 09:37 AM   PM User | #2
Major Payne
Regular Coder

 
Join Date: Aug 2005
Location: MS
Posts: 745
Thanks: 7
Thanked 65 Times in 63 Posts
Major Payne is an unknown quantity at this point
Can't center elements when 100% width or floated left/right:

Centering:

Centering an element requires setting a width that is less than 100%, using a proper document type and using the CSS property: margin: 0 auto; This is done in the CSS that styles the element. Example:

Code:
body {
width: 90%;
height: 600px; /* optional */
margin: 0 auto;
background: #fff url(path to non-tiled image) no-repeat center scroll;
}
Example as a Class:
Code:
.selector_name {
width: 90%;
height: 600px; /* optional */
margin: 0 auto;
background: #fff url(path to non-tiled image) no-repeat center scroll;
}
HTML for Class:
Code:
<div class="selector_name">Content here</div>
Example as an ID:
Code:
#selector_name {
width: 90%;
height: 600px; /* optional */
margin: 0 auto;
background: #fff url(path to non-tiled image) no-repeat center scroll;
}
HTML for Class:
Code:
<div id="selector_name">Content here</div>
Change parameters as you need. Set "#fff" to background color you want. Set "scroll" to "fixed" if you want page contents to scroll over background image. CSS was given for an image that does not tile. Doesn't have to be the body tag, but you should get the idea.

Validating:

Why Validate?: http://validator.w3.org/docs/why.html
CSS Validator: http://jigsaw.w3.org/css-validator/
HTML Validator: http://validator.w3.org/#validate_by_uri+with_options

Choosing Dimensions for Your Web Page Layout:

In Search of the Holy Grail: http://www.alistapart.com/articles/holygrail/
Choosing Dimensions for Your Web Page Layout: http://www.elated.com/articles/choos...b-page-layout/
How to create flexible sites quickly using standards like CSS and XHTML: http://www.ibm.com/developerworks/web/library/wa-rapid/
Care With Font Size: http://www.w3.org/QA/Tips/font-size
Designing for the Web: Resolution and Size: http://sitepointcom.createsend4.com/...yd/birtthtw/h/

Websites Shouldn’t Look The Same Across Different Browsers: http://www.noupe.com/design/websites...re-is-why.html
Cross-Browser CSS in Seconds with Prefixr: http://net.tutsplus.com/articles/new...-with-prefixr/
Responsive Web Design Demystified: http://www.elated.com/articles/respo...n-demystified/
Responsive Web Design: 5 Handy Tips: http://www.elated.com/articles/respo...-5-handy-tips/
It’s Not Responsive Web Building, It’s Responsive Web Design: http://www.getfinch.com/finch/entry/...ve-web-design/

Beginner’s Guide to Responsive Web Design: http://thinkvitamin.com/design/begin...ve-web-design/

Adapt.js - Adaptive CSS: http://adapt.960.gs/
__________________
☠ ☠RON☠ ☠
Major Payne is offline   Reply With Quote
Reply

Bookmarks

Tags
background, css, float, width

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:36 PM.


Advertisement
Log in to turn off these ads.