Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

marjetapunik
marjetapunik
907 Points

Empty DIV does not take place

Hello!

I'm new in designing websites and need a little help.

I made a one page site that consists of a grid (vertical and horizontal spaces).

In view websites we empty DIV does not take space and throws all elements on the left side.

I have tried adding a min-height: 1px and adding an empty space in the element. But nothing works.

Could you advise what can I do?

4 Answers

marjetapunik
marjetapunik
907 Points

It is not in EN language, so don't be affraid. I used this tutorial on making grid: http://j4n.co/blog/Creating-your-own-css-grid-system>

Text should be on the right half of a page. My code is:

    <section id="onas">
            <div class:"row">
                <div class="st-8">
                </div>
                <div class="st-5">
                    <p>Smo dru&#382ba za integrirano komunikacijo!</p>
                </div>
                <div class="st-2">
                </div>
            </div>
        </section>
    ```


```css
/* mreza = whole document*/
.mreza {
    width : 100%;
    max-width : 1200px;
}


.row:before, 
.row:after {
    content: "";
    display: table;
    clear:both;
    visibility: hidden;
}


/*st = vertical grid */
.st {
    float: left;
    min-height: 1px;
}

.st-2 {
    width: 13,32%;
    float: left;
    min-height: 1px;
}

.st-5 {
    width: 33,3%;
    float: left;
    min-height: 1px;
}

.st-8 {
    width: 53,28%;
    float: left;
    min-height: 1px;
}

THANK YOU!

Wayne Priestley
Wayne Priestley
19,579 Points

Hi,

You have a typo,

<div class:"row"> <!-- should be class="row" -->
Wayne Priestley
Wayne Priestley
19,579 Points

Hi marjetapunik,

The answer really depends on if you using floats or not and how your div's are displayed e.g block or inline-block.
You could add &nbsp; to the div if you ARE using floats.

or:

.left-column
{
   width: 200px;
   min-height: 1px;
   float: left;
}

.right-column
{
    width: 500px;
    min-height: 1px;
    float: left;
}

One way with inline-block is:

.class:after {
    content: '.';
    visibility: hidden;
}

If your still having problems, try posting your html and css.

Here is a link to explain how to use Markdown to post your code How to post code

If you look at the bottom of the box when your typing a reply you will see Markdown Cheatsheet that will also explain how to post your code.

You have to make sure you have a bit of space under your last line of text in your post. Then you add three back ticks followed by html or css depending on the type of code your inserting.
Then straight after your last line of code you add another three back ticks.
Remember to leave at least a few lines between any text at the top or bottom of your code.

alt text

Hope this helps.

marjetapunik
marjetapunik
907 Points

Ups, thank you! I've changed it.

But sadly it still doesn't work. It must be something small and I just can't see it now.

marjetapunik
marjetapunik
907 Points

I used min-height: 1px;

And I found out that I had different hierarchy of elements.

Order that worked for my page:

  1. Container (it contains whole section of a web page),
  2. inside I divided container with whole grid (section of 12), and I added clearfix !
  3. I split grid elements in a div (the sum is always 12).

like this:

    <!DOCTYPE html>
        <head>
              <div class="container">
                    <div class="grid_12 clerafix">
                          <div class="grid_8"></div>
                          <div class="grid_4"></div>
                    </div>
              </div>
        </head>
    </html>
    ```