How can I set the height of my website to be the same height as the visible browser window, with no vertical scrolling?


Question

I want to design a portfolio website, and I don't want it to scroll vertically.

What are the dimensions for this kind of website, like the standard browser height?

How can I create a website that's the same size as the visible height of the browser?

1
1
7/6/2014 3:04:00 AM

Accepted Answer

These days webdesignerd tend to use responsive values. So make it responsive by using %. Although this makes using images tricky

0
7/5/2014 7:24:00 AM

The dimensions are variable.

User Joojaa is correct when they say that "You can no way know what size or shape the recipients screen is going to be."

You cannot set any explicit value in your CSS, because if you want to consistently support all browsers, you have no way of knowing what size it's going to be.

I'm going to give you one method, using just HTML and CSS. I have briefly tested a basic version in Chrome and IE. It's fine back to IE7, and then the vertical alignment drops out, but the single page with no scrolling remains intact as far back as IE5(!).

Here's an image of the result (click on the image to go to a working example on jsFiddle):

enter image description here

In case my example link goes dead, here's the code for my mockup:

The HTML:

<body>
    <div class="centered-container">
        <div class="content">
            <div class="name">
                Eileen Dover
            </div>
            “I'm part of the 21<sup>st</sup> century now.<br> I have an online portfolio!”
            <br>
            <br>
            <a href="#">Click here to see some of my awesome work!</a>
        </div>
    </div>
</body>

The CSS:

body {
    width:100%;
    height:100%;
    background:#191970;
    padding:0;
    margin:0;
    font-size:10px;
    font-family: 'Open Sans', sans-serif;
}

.centered-container {
    position:absolute;
    left:5%;
    right:5%;
    top:5%;
    bottom:5%;
    background:#fff;
    display:table;
    width:89%;
    height:89%;
    margin:0 auto;
}

.content {
    position:relative;
    display:table-cell;
    vertical-align:middle;
    text-align:center;
    font-weight:400;
    font-size:2.500em;
    color:#191970;
    border-top:4px ridge #4c4ca3;
    border-left:4px ridge #4c4ca3;
    border-bottom:4px groove #4c4ca3;
    border-right:4px groove #4c4ca3;
}

.name {
    font-size:3.500em;
    font-weight:700;
    padding:0.050em 0;  
}

This is the most I can do for you at the moment. I have no idea how much HTML, CSS or JavaScript you know, but if you really want to make this, you should learn a bit and make a plan. This kind of website will only work with certain kinds of designs. Namely, ones with minimal text.

Good luck with your project.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
^