Search code examples
htmlcsswebresolution

Layout changes when I switch resolution


I'm making a website (in Dutch) and I work on a laptop with a external screen. The external screen has another resolution then my laptop screen so the site comes out distorted when viewed on the other screen. How do I fix this?

<!DOCTYPE HTML>

<html>

<head>  <style type="text/css">

body {
    background-color: #D8D8D8;
}
nav {
/* Dit is voor de menubalk bovenin. */
position: relative;
background-color: black;
width: 100%;
height: 110px;
top: -16px;
left: -7.8px;
padding: 8px;
}
.menutekst1 {
position: relative;
width: 150px;
display: inline;
border-color: white;
color: white;
list-style-type: none;
float: right;
font-size: 39px;
top: 10px;
right: 40px;
font-family: verdana;

}
.menutekst2 {
position: relative;
display: inline;
border-color: white;
color: white;
list-style-type: none;
float: right;
font-size: 39px;
top: 10px;
right: 25px;
font-family: verdana;
}
.menutekst3 {
position: relative;
display: inline;
border-color: white;
color: white;
list-style-type: none;
float: right;
font-size: 39px;
top: 10px;
right: 50px;
font-family: verdana;
}
.menutekst4 {
position: relative;
display: inline;
border-color: white;
color: white;
list-style-type: none;
float: right;
font-size: 39px;
top: 10px;
font-family: verdana;
}
#logo {
/* Dit is voor het logo rechts bovenin. */
position: absolute;
top: 30px;
left: 0px;
width: 300px;
}
#facebook {
/* Dit is voor het Facebook logo rechts bovenin. */
position: absolute;
top: 30px;
left: 320px;
width: 70px;
}
#hometekst {
/* Dit is voor de tekst op de home pagina. */
position: relative;
text-align: center;
font-size: 20px;
font-family: Verdana;
}
#home1 {
position: relative;
display: inline;
width: 250px;
height: 161px;
float: left;
left: 0px;
/* left: 40px; */
}
#home2 {
position: relative;
display: inline;
width: 320px;
height: 161px;
float: right;
left: px;
right: 250px; */
}
#home3 {
position: relative;
display: inline;
width: 250px;
height: 161px;
float: right;
/* right: 50px; */
}

</style>

</head>

<body>

<nav>
    <ul>
        <img id="logo" src="Foto/logoalgemeen.png" />

        <a href="https://www.facebook.com/pages/Ve-screen-Ve-woning-en-scheepsstoffering/369675879764436?fref=ts" target="_blank" title="Facebook"><img id="facebook" src="Foto/facebookalgemeen.png" /></a>

        <div class="menutekst4"><li>Contact </li></div>
        <div class="menutekst2"><li>Wat doen wij  </li></div>
        <div class="menutekst3"><li>Producten</li></div>
        <div class="menutekst1"><li>Home</li></div>

    </ul>
</nav>

<p id="hometekst">

    <strong>Welkom bij VE-Screen</strong><br>
    Ve-stoffering is een betrouwbare partner, denkt met u mee<br>
    en weet wat kwaliteit is of het nu gaat om uw woning, schip<br>
    of kantoor.<br>
    Onze kracht is de ervaring en goede samenwerking met u<br>
    als klant, de interieurbouwers en andere aannemers zodat<br>
    alles perfect op elkaar afgestemd en opgeleverd wordt.<br>
    Desgewenst incl. stoffering van banken, het leveren van<br>
    matrassen en bedtextiel en natuurlijk het plaatsen van ons<br>
    eigen Ve-screen zonwering.
</p>

<img id="home3" src="Foto/home3.png" />
<img id="home2" src="Foto/home2.png" />
<img id="home1" src="Foto/home1.png" />

</body>

</html>

Solution

  • I think it's because you're using the width as a percentage, then positioning your buttons absolutely. This means that the 100% value will adapt to the screen size but not the buttons' positions as they will always be absolutely positioned using the same values for each screen.

    One solution could be to use one precise width value, another solution would be not to absolutely position the buttons and instead use the floatproperty for the buttons. Hope this helps.