I have tried several different sources on the Internet. I am not using bootstrap; I enjoy doing my site from scratch. It helps me program.
I can't get my web page to auto adjust to the screen size. For example if you make the browser smaller the page collapse nice and neat.
I tried these codes from here:
but my web page doesn't collapse like the example.
<!--
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true"> -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="sunpacking.css">
<title>Sun Packing WebSite</title>
<link href="../../Documents/Sun Packing/sun.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.div1 { margin: 20px;
}
</style>
</head>
<body>
<div>
<div>
data
</div>
/*Sun Packing CSS */ /*
body{ padding:0px;
margin:0px;
width:100%;
height:100%;
}
*/
#container { float: none; border-style: dashed; border-color: red; width: 100%; /* 95px*/ height: 100%; /*1400px*/ color: red;
} 3 2 Answers
You could start by closing your HTML containers, and giving a good example of what you've tried.
If you set an explicit width, width: 800px;, that's the width it will be rendered at.
Try setting the container's max-width for that and set the width to expand to that
The way that I usually do it:
.container { max-width: 800px; width: 100%;
} Try using percentages instead of pixels. Pixels will give you a fixed width. Percentage with keep thing proportional.
Here is a good article to help you understand what the different measurements mean. Once you understand what they mean, you should be able to make a better selection depending on the usage you expect.
1