Currently, my friend and I are collaborating on a mod for the popular game known as Minecraft
. My responsibility is to create a website where we can showcase this mod and provide information about its features.
The main issue I am encountering is the inability to make objects within the webpage adjust their size in accordance with different browser resolutions. At present, the layout of the page is tailored to fit my screen resolution (1920 x 1080), which works well; however, when the window is resized smaller, horizontal scrolling becomes necessary to view various sections of the HTML page.
My goal is for the content to dynamically adjust to fit any window or screen resolution.
How can I ensure that the objects on my page change size based on the window's dimensions?
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="MOPM-ico/favicon-144.png">
<meta name="msapplication-config" content="MOPM-ico/browserconfig.xml">
<link rel="shortcut icon" href="MOPM-ico/favicon.ico">
<link rel="icon" sizes="16x16 32x32 64x64" href="MOPM-ico/favicon.ico">
<link rel="icon" type="image/png" sizes="310x310" href="MOPM-ico/favicon-310.png">
<link rel="icon" type="image/png" sizes="196x196" href="MOPM-ico/favicon-196.png">
<link rel="icon" type="image/png" sizes="160x160" href="MOPM-ico/favicon-160.png">
<link rel="icon" type="image/png" sizes="96x96" href="MOPM-ico/favicon-96.png">
<link rel="icon" type="image/png" sizes="64x64" href="MOPM-ico/favicon-64.png">
<link rel="icon" type="image/png" sizes="32x32" href="MOPM-ico/favicon-32.png">
<link rel="icon" type="image/png" sizes="16x16" href="MOPM-ico/favicon-16.png">
<link rel="apple-touch-icon" sizes="152x152" href="MOPM-ico/favicon-152.png">
<link rel="apple-touch-icon" sizes="144x144" href="MOPM-ico/favicon-144.png">
<link rel="apple-touch-icon" sizes="120x120" href="MOPM-ico/favicon-120.png">
<link rel="apple-touch-icon" sizes="114x114" href="MOPM-ico/favicon-114.png">
<link rel="apple-touch-icon" sizes="76x76" href="MOPM-ico/favicon-76.png">
<link rel="apple-touch-icon" sizes="72x72" href="MOPM-ico/favicon-72.png">
<link rel="apple-touch-icon" href="MOPM-ico/favicon-57.png">
<link type="text/css" rel="stylesheet" href="styles.css" />
<title>
MOPM~
</title>
</head>
<body>
<header>
<!--header-->
<div class="topHead">
<img id="headertxt" src="pictures/header.png" width="1919px" height="120px"/>
</div>
<!--header buttons-->
<div class="headButtonSeperator">
<div class="headButton">home</div>
<div class="headButton">about</div>
<div class="headButton">mod info</div>
<div class="headButton">downloads</div>
<div class="headButton">videos</div>
<div class="headButton">links</div>
<div class="headButton">dev team</div>
</div>
</header>
<!--content-->
<div id="home">
</div>
</body>
</html>
CSS:
body
{
background-image: url('pictures/background.png');
}
/*--Classes--*/
.topHead
{
width: 1919px;
height: 120px;
background-color: #272B30;
float: middle;
position: absolute;
margin: auto;
top: 0px;
left: 0px;
right: 0px;
display: block;
border-bottom: 4px dashed #1EC20B;
}
.headButtonSeperator
{
width: 980px;
height: 40px;
background-color: none;
position: absolute;
top: 125px;
left: 509px;
}
.headButton
{
width: 120px;
height: 10px;
background-color: #313A3D;
margin-left: 5px;
display: inline-block;
float: left;
font-size: 0px;
border-left: 3px solid #282E30;
border-bottom: 3px solid #282E30;
border-bottom-left-radius: 20px;
}
.headButton:hover
{
width: 140px;
height: 35px;
background-color: #313A3D;
margin-left: 10px;
position: relative;
display: inline-block;
color: #DB481B;
font-size: 20px;
text-align: center;
line-height: 35px;
font-family: minecraft;
text-shadow: 2px 2px #7A5E55;
border-left: 3px solid #282E30;
border-bottom: 3px solid #282E30;
border-bottom-left-radius: 20px;
}
/*--ID's--*/
#home
{
display: block;
width: 918px;
height: 1000px;
background-color: white;
position: absolute;
top: 500px;
left: 500px;
float: middle;
z-index: -1;
}
/*--Fonts--*/
@font-face
{
font-family: minecraft;
src: url(fonts/minecraft.ttf);
}
@font-face
{
font-family: McBold;
src: url(fonts/ARCADEPI.ttf);
}
@font-face
{
font-family: McBlock;
src: url(fonts/Square.ttf);
}
@font-face
{
font-family: MccBlock;
src: url(fonts/Squareo.ttf);
}
Edit: I haven't received any responses yet, but I am eager to resolve this issue so I can proceed with other elements of the webpage.
Should I consider using percentages? What adjustments do I need to make to ensure proper positioning based on varying resolutions and window sizes?
Edit:
After some experimentation, I've realized that creating a responsive design involves avoiding the use of fixed pixel values (px
). Can you guide me on making the page responsive and suggest appropriate units of measurement?
Edit:
I experimented with percentages, but it did not yield the desired results.
In the image linked below, I tested setting the width of the header banner to 100%.
Upon resizing the window, the top text (an image) did not resize accordingly.
http://prntscr.com/47v2ub <---image
Edit: Following up on the previous edit: I realized that I needed to set >.topHead width to 100
Now, the issue I'm facing is that if the browser window shrinks too much, all my buttons end up clustered together.