Results 1 to 7 of 7

Thread: My first try at positioning elements with CSS - a non-table approach to page layout

Hybrid View

  1. #1
    Join Date
    Dec 2009
    West-Central, MN

    Question My first try at positioning elements with CSS - a non-table approach to page layout

    Hi all,

    I'm really not having too much luck at all with my first attempt at CSS-only page layout.

    Here's the URL for what I'm working on: http://dev.eventidewebdesign.com/ken...n/newhome2.php

    Here's the code for the whole page:
    HTML Code:
    <!DOCTYPE html>
    <html lang="en">
    		<title>Home Page</title>
    	<body style="margin: auto; width: 1000px; font-size: .8em;>
    		<div id="header" style="display: inline; height: 200px; background-image: url(images/header.png); background-repeat: no-repeat; background-attachment: fixed; background-position: center 5px;">
    		<h2>Proof the image is there:</h2>
                    <p>The below image should be at the top of the page!</p>
    		<img src="images/header.png" />
    I can't get the image to display. (Aside from the <img> tag to show it's really there,) I can get it to display as a background image of the <body> tag, but I thought it would be better practice to put it in a <div> as a child of <body>. Also, I have to put a nav menu and image in a div immediately below the header image on the left side of the page (they will mesh seamlessly and look like they are one image).

    What am I missing here?
    Eventide Web Design, LLC

  2. #2
    Join Date
    Aug 2012
    Firstly can I please advise that if you are going to go down the route of using CSS (which you should) then please start as you mean to go on (or should) and don't style inline - put all your styles in an external stylesheet. With regard to your style problem, you can put all your separate background style properties in one like so (basing on moving your styles to a stylesheet, not using inline)
    #header {
      background: url('images/header.png') no-repeat fixed center 5px;
      height: 200px;
    Try this and see if it works (put it inline if you must to test first).

  3. #3
    Join Date
    Dec 2009
    West-Central, MN
    I should have added a disclaimer! Yes, I will move everything to a separate stylesheet eventually. When I'm just getting started I do inline styling because it's easier than switching back and forth between files as I make constant adjustments. When I'm happy with everything, I'll separate the CSS out.

    I tried your suggested code, but it didn't work. See here.
    Eventide Web Design, LLC

  4. #4
    Join Date
    Aug 2012

    However, looking at your source code (keeping things inline for you at the moment) your code is incorrect as you have not declared style. Try

    <div id="header" style="background: url('images/header.png') no-repeat fixed center 5px; height: 200px;"></div>

  5. #5
    Join Date
    Dec 2009
    West-Central, MN
    Well, that is embarrassing! I even found a missing double quote to close the <body> styling!

    But I fixed those and that still didn't get the image to show...

    I tried adding "display: inline:" to the image div, but that didn't have an effect, either.
    Eventide Web Design, LLC

  6. #6
    Join Date
    Aug 2012
    I have just altered the css in your page (online) and removed the display: inline and the image appears

  7. #7
    Join Date
    Dec 2009
    West-Central, MN
    This has been resolved by an awesome dude over at HTML forums. For a view of what I wanted ultimately, go to http://dev.eventidewebdesign.com/ken...de/newhome.php. You'll have to hurry if you want to see it, though, as I'm about to move those files to get ready for continuing my work on this project...

    If I've moved them and you'd like to see the result email me via my profile and I'll get back to you.
    Eventide Web Design, LLC

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13148 seconds
  • Memory Usage 3,105KB
  • Queries Executed 13 (?)
More Information
Template Usage (31):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates