1
    body  {
     background-color: white;
     color: #000000;
     font-family:"arial",arial;
     margin:auto;
     }



(header logo EWITA)    #header {
      position:relative;
      left:-150px;
      background-color:transparent;
      text-align:center;
      margin-top:50px;
      padding:0;}



(HR LINE)    hr.main {

      position:relative;
      top:-5px;
      background-color:#353535;
      height:10px;
      width:100%;
      margin:0;
      padding:0;
      z-index: -1;

      }

       #menubar {
     position:relative;
     background-image: URL('./pictures/menu.png');
     background-repeat:no-repeat;
     left:730px;
     top:-40px;
     height:25px;
     width:300px;
     background-color:transparent;
     color:#ffffff;
     padding:5 0 0 20;
    }


(menu bar)    table,tr,td {
      border-spacing:0;
      border-collapse:collapse;
      padding:0 10 0 10;
    }





(page after head)     #wrapper {

       margin:auto;
       min-height:500px;
       background-image: URL('./pictures/background.png');
       background-repeat: repeat-xy;
       z-index:-2;
       }



    #content {
      margin:auto;
      width:700px;
      background-color:#ffffff;
      margin-top: 40px;
      border:1px solid;
      padding: 50 30 50 30;

this is my css i am writing a page for a client and due to some relative positioning it makes me a problem with a background as u see here the white line after the HR line.

Thanks everyone who responds.

RevanthKrishnaKumar V.
  • 1,855
  • 1
  • 21
  • 34
Vova
  • 37
  • 1
  • 5
  • 1
    white line? your whole page is white please be more specific. – Banana Mar 16 '14 at 20:53
  • http://s020.radikal.ru/i714/1403/b8/1c656dd41b0b.png under blue is a background. I know that its really bright, anyway .. ^^ – Vova Mar 16 '14 at 20:57
  • 1
    `margin-top: 40px;` on `#content` is causing a good portion of the issue you are talking about – anurupr Mar 16 '14 at 21:07
  • i want it with that margin... but on a background (but there is just WHITE) – Vova Mar 16 '14 at 21:20

2 Answers2

4

Edit:

Wondered how to update this answer, as there is a lot to talk about found it best to take it from bottom up. This will bring you to a layout like this:

The menu and logo should stay in place when you re-size the window etc.


Had a look at your code now. It is better, but you still have some trouble:

  1. border is still set on image. Invalid markup.
  2. repeat-xy is still used on background. Invalid property value.
  3. #content still has padding without units. Invalid property value.
  4. <br> tags are still used to make paragraphs in text.
  5. There is an extra } after #content. Invalidates CSS file.

Number 4. should be fixed, but not that important right now.

As we already have discussed 1-3 it is hard to understand why you keep them. Invalid markup and styling makes for unreliable result.

It can look OK in one browser, in one version of one browser, look whack in another, and totally break in a third. You get misinformation between code and result. When or if you fix it to be valid other unexpected things may change and you have to do a lot more work to clean it up. As a whole and rule number one. No matter how wrong markup and styling might be seen from a how to do it perspective one have to keep invalid markup and style out of it.

To validate your work, and as you are where you are in regards to experience, do it all the time. Do small changes: validate. Do small changes: validate. And so on. Use:


Markup

The markup as it is now is not the easiest to style or get to behave good in a dynamic way. hr's is not the easiest to work with and vary between browsers. Do not use tables for menu's or styling. They are best left for what they are intended to: show tabular data. For your menu you can ask yourself: what is the menu; well, it is a list. A list of options for end-user to navigate trough the site. There is a lot of examples on the web using lists as menus. Search the web for CSS list menu etc. You can create nice looking, cross-browser reliable CSS only, (no JavaScript dependency), menus.


But let us start with the basic markup: You will usually find it good to wrap the whole page inside a wrapper. Then add sub-items into that. To position elements like your main menu, logo etc. it could be good to use a wrapper for each and position them by float, margins etc.

In general use margins and padding.

Page layout

               Head                 
Div
              Divider                Div

            Content                


Div
             Footer                  Div

Head
   Div float left   Div float left

      LOGO
menu                 

Styling + markup

To make it easy for yourself use temporary borders and background colors to view how the various elements float around. Also use the browsers built-in tools to show various things like margins etc. This is invaluable.

Only remember that if you use borders, and you intend to remove them on finished product, they can take up space.

As an example you could have something like this:

HTML:

<div id="wrap">
    <div id="head">
        <div id="logo">
            <a href="index.php">
                <img id="logo_img" src="http://cupido.g6.cz/pictures/header.png" alt="EWITA" />
            </a>
        </div>
        <div id="menubar">MENU</div>
    </div>
</div>

CSS:

* {
    margin     : 0;
    padding    : 0;
}
body {
    font-family: Arial;
    height     : 100%;
    background : orange;
}
#wrap {
    position   : relative;
    background : pink;
    width      : 100%;
    height     : 100%;
}
#head {
    position   : relative;
    width      : 800px;
    height     : 131px;
    margin     : 100px auto 0 auto;
    background : blue;
}
#logo {
    position   : relative;
    width      : 431px;
    float      : left;
    background : red ;
}
#logo_img {
    width      : 439px;
    height     : 131px;
    float      : left;
}
#menubar {
    position   : relative;
    background : #fff;
    width      : 300px;
    float      : left;
    margin-top : 107px;
    padding    : 3px 0 3px 10px;
}

Note: I use a hard reset of margin and padding on all elements by:

* {
    margin : 0;
    padding; 0;
}

And then set margins and padding on tags and elements as I use them. Often find this to be a much easier way then the other way around. Remember that things like body also has padding etc. and often can result in undesired spacing.

This way you also get rid of the horizontal scroll-bar at bottom.

By using float on thing like logo and menubar the elements align nicely.


Next we can add the divider. Here we could use a div and set border for top and bottom. On content we use padding to make space between header, text and footer. We also add white border to top of content that aligns nicely with the divider.

HTML:

<div id="divider"></div>
<div id="main_content">
    MAIN CONTENT
</div>
<div id="footer">
    FOOTER
</div>

CSS:

#divider {
    border-top   : 5px solid #353535;
    border-bottom: 3px solid #888;
}
#main_content {
    position   : relative;
    background : url('http://cupido.g6.cz/pictures/background.png');
    border-top : 2px solid #fff;
    padding    : 120px 0 130px 0;
}

Next we can add the content text and style it. Also added style to footer.

HTML

<div class="content_text">
    <p>
        text text text ...
    </p>
</div>

CSS:

.content_text {
    margin     : 0 auto;
    width      : 700px;
    background : #fff;
    border     : 1px solid;
    padding    : 50px 30px;

}
.content_text p {
    font-size  : 16px;
}

Resize window etc. and see it floats nicely around.


Now it is time to add the menu. As mentioned earlier we can use list for the menu. It is much more suited for the task then a table. In that regard also note that a menu might have sub items, as such a list becomes the only sane option.

Also note on the menu: You likely do not want to style visited links with other color. But that is up to you of course.

HTML:

<ul>
    <li><a class="menu" href="smaler.php">úvodní&nbsp;stránka</a></li>
    <li><a class="menu" href="sluzby.php">služby</a></li>
    <li><a class="menu" href="kontakt.php">kontakt</a> </li>
</ul>

CSS:

As we already have set margins and padding to 0 on all elements this is trivial:

#menubar ul {
    list-style : none;
}
#menubar li {
    padding    : 0 10px;
    float      : left;
}
a.menu {
    text-decoration : none;
    color      : #fff;
}
a.menu:hover,
a.menu:active {
    color      : #3cc8a8;
}

Remove helping colors etc. and we have a version 0.1 ready for further testing and expansion.


Original answer:


There is more then one problem. Firstly the markup:

XHTML

<link rel="icon" type="image/png" href="./pictures/favicon.png">
Should be:
<link rel="icon" type="image/png" href="./pictures/favicon.png" />

<link rel="stylesheet" type="text/css" href="style.css">
Should be:
<link rel="stylesheet" type="text/css" href="style.css" />

<img src="./pictures/header.png" width="439" height="131" border="0" alt="">
Should be XHTML 1.0 Strict img tag does not have a border attribute, and need
to be closed:
<img src="./pictures/header.png" width="439" height="131" alt="" />

<hr class="main" /></hr>
Should be:
<hr class="main" />

Use paragraphs to group text, not:

Text<br/><br/>Text<br/><br/>Text ...

but:

<p>Text</p><p>Text</p><p>Text... </p>

CSS

Inline comments are not valid, use:

/* some comment */
Not:
// some comment

You are missing unit on most of your padding values. If a value is non-zero it needs a unit such as pt, px etc. Use:

padding: 5px 0 0 20px;
/* Not: */
padding: 5 0 0 20;

If you do not, it has no/(should not have any) effect.

background-repeat does not have repeat-xy. Use:

background-repeat: repeat;
/* not */
background-repeat: repeat-xy;

or nothing at all, as that is the default.


Fix those first. Then set some color to your things so that it is easier to understand what you want. You can change them back later. Use red, blue etc.

Example.


Regarding zero width no break space bug, as displayed in Vim:

enter image description here

user13500
  • 3,817
  • 2
  • 26
  • 33
  • @Vova: Glad you found it helpful. Also note that I have added some notes in the final CSS. I am far from fully learned, guess no one are, on HTML, CSS etc. The post is also short, (even though it is long for this site ;). End result could be OK as a starter, but you likely will find things you need to change (if you use any of it). Strongly recommend you read this: http://docs.webplatform.org/wiki/css/tutorials to familiarize yourself with many of the topics. They also have HTML articles etc. – user13500 Mar 18 '14 at 12:31
  • @Vova: Also. My reset in the code is rather crude. Search the Web for things like *CSS reset* to look at the topic. For example this: http://stackoverflow.com/q/11578819/3278057 You might find you want to include something like this http://meyerweb.com/eric/tools/css/reset/ atop your CSS or the like. It all depends on needs. – user13500 Mar 18 '14 at 12:37
  • now... i am almost finished with all the changes... when i converted it into PHP and uploaded it on the web... it shows me a hole in divs between main content and footer - as u can see here: http://gvp.cz/~mryshchuk/index.php otherwise...through html everything works perfectly (http://gvp.cz/~mryshchuk/pc-servis.html) – Vova Apr 19 '14 at 15:47
  • @Vova: You have a invisible 0xfeff byte just before the footer opening `
    – user13500 Apr 19 '14 at 15:57
  • Result looks like this: ` ` where `` is a byte, likely a stray one in your PHP file. Set your editor to show invisible characters and remove it. – user13500 Apr 19 '14 at 15:57
  • i toggled hidden chars...but i cant see any :( – Vova Apr 19 '14 at 16:04
  • @Vova: It is a `ZERO WIDTH NO-BREAK SPACE` if you are interested. In other words it is a *space with no width* that does not break! It should give you the bug you experience. As it does not have any width it will be invisible (unless you use *show invisible space* or the like in editor.). The `` should show in e.g. Vim. What editor do you use? It does not necessarily show you `` (if you are using other editor), but any decent editor should give you some sort of indication of the glyph. – user13500 Apr 19 '14 at 16:06
  • @Vova: OK. I'm on Linux. Have to boot up a XP box to check. – user13500 Apr 19 '14 at 16:13
  • @Vova: It shows up as a glyph similar to `[` in HTMLPad 2014. – user13500 Apr 19 '14 at 16:16
  • @Vova: If you can't find it the simplest is to simply delete the whole line and the line before it and type it in manually. That is: if you do not do any `` to produce the markup right there. – user13500 Apr 19 '14 at 16:22
  • thats what i see...https://www.dropbox.com/s/2zn9vc1neclzs8s/V%C3%BDst%C5%99i%C5%BEek.JPG – Vova Apr 19 '14 at 16:22
  • @Vova: That's to bad. Looks like they have extended it somewhat to the 2014 version. Anyhow: Try to place your cursor *inside* the footer div `. Then backspace up to previous line and enter new opening `<` – user13500 Apr 19 '14 at 16:26
  • @Vova: It could come from the include file (index.php?) ... as in not the included file (footer.php). – user13500 Apr 19 '14 at 16:28
  • done, but nothing happened https://dl-web.dropbox.com/get/aas.JPG?_subject_uid=263544901&w=AAC90RSIWlVAJyx0LvKff-1lvBigFgrdYOl7vi1ErX5VdA – Vova Apr 19 '14 at 16:30
  • @Vova: Or you could download Vim (it is free) and open the files there. Note that vim is a modal editor and as such somewhat trickier to use. Open the file(s) in Vim and see if you find it. If you do place your cursor on the `` and enter `dw` to delete it. Then `:w` to save. (Or use some other editor Notepad++ perhaps, but I'm not sure if it displays the glyph as is or not) – user13500 Apr 19 '14 at 16:33
  • @Vova: Added a picture showing you how it displays in Vim. – user13500 Apr 19 '14 at 16:39
  • @Vova: Yes. Now the dropbox image is viewable as well. What about where you include the file? From image I can only see where you include `header.php` and not `footer.php` – user13500 Apr 19 '14 at 16:46
  • https://www.dropbox.com/s/3uoh00ep4zpqv0r/ewita.rar here is the whole folder... edit it and show me what u did. – Vova Apr 19 '14 at 16:47
  • @Vova: Ah. The file has a byte order mark `0xefbbbf`. This won't show up in editor and will mangle result. You have to save the file without BOM. http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8 At least in HTMLPad 2014 you can do `save as` and select save without BOM. – user13500 Apr 19 '14 at 17:04
  • In Vim you can check if file has BOM by entering: `:set bomb?` It yield `bomb` if there is BOM and `nobomb` if there is none. To remove it enter `:set nobomb` and then save by `:w` – user13500 Apr 19 '14 at 17:12
  • @Vova: In general BOM is not recommended for UTF-8. UTF-8 is byte order agnostic and using it, especially in web-content and PHP files will only cause headache (as you/we now have witnessed). It was a rather nasty bug. Look in HTMLPad if there is an option to ***not*** use BOM on UTF-8 by default (so that you do not some day forget to remove it and another weird bug appear). – user13500 Apr 19 '14 at 17:24
  • @Vova: Also do not forget to [validate](http://validator.w3.org/) your work, as mentioned earlier. Both HTML and CSS. Good work and good luck :) – user13500 Apr 19 '14 at 17:30
  • Hi! I changed it to utf without bom... now everythings works correctly, thank you very very much :) for your time especially. – Vova Apr 20 '14 at 17:41
0

Try adding this CSS:

CSS:

#wrapper {

margin: auto;
min-height: 500px;
background-image: URL('../images/squared_metal.png');
background-repeat: repeat-xy;
z-index: 10;
padding-top:10px;
margin-top:-30px; 
}

#content {
margin:auto;
width:700px;
background-color:#ffffff;
margin-top: 10px;
border:1px solid;
padding: 50 30 50 30;
}

I totally overlooked the 'padding-top' css property originally. Thank you all for providing that information!

Please update your site with this CSS and let me know if it works! Since I tested this on my own machine, you should change back the background-url to your custom .png file.

Jeff P.
  • 2,754
  • 5
  • 19
  • 41
  • yes, i have tried it... look at it now. i also made a change at this #content { margin:auto; width:700px; background-color:#ffffff; margin-top: 40px; **(> 80 PX)** border:1px solid; padding: 50 30 50 30; If i had left 40, it came to the position right under the line, but i want the content div to be a 20 px under the line... but already with a background.. having troubles :((( – Vova Mar 16 '14 at 21:17
  • Do you want no whitespace at all? – Jeff P. Mar 16 '14 at 21:19
  • Right, i dont want it at all. – Vova Mar 16 '14 at 21:32
  • I noticed you made margin-top in your 'content' id to 80px, why don't you just leave it at 40px so that there will be no whitespace between the header and wrapper? – Jeff P. Mar 16 '14 at 21:35
  • because i want the #content a bit lower on the page.. As I have written, if it was 40, then it was ok, without a whitespace, but just under the gray line... regrettably its not what i want. – Vova Mar 16 '14 at 21:39
  • Give me a few minutes, I think I know what you want now. – Jeff P. Mar 16 '14 at 21:43
  • now its perfect...http://cupido.g6.cz/index.php i just used -35px margin top; and as well padding-top 50px. – Vova Mar 17 '14 at 09:30