html - 监控分辨率改变网站的外观

标签 html css layout

我有一个网站,在我的分辨率下甚至在更常见的 1024 x 768 下看起来都不错。但是,在其他人的 1024 x 768 浏览器中,它太宽了,网站甚至没有正确居中。

有没有一种方法可以在分辨率改变时保持适当的宽度布局不变?

/* Body */
body {
    background: #535353;
    font-family: Arial;
    font-size: 12px;
    color: Black;
}

form {
margin:0;
padding:0;
display: inline
}

* {
    margin: 0;
    padding: 0;
}

/* Header */
#header {
    margin-left: 100px;
    margin-right: 100px;
    overflow: hidden;
}

/* Logo */
#logo 
{
    background-color: White;
}

/* Menu */
#menu {

    margin-left: 100px;
    margin-right: 100px;
    margin-top: 0px;
    margin-bottom: 0px;
    padding: 0 0 0 0;
    text-align: left;
    background-color: #AB0000;
    font-size: 14px;
    color: White;
    font-weight: bold;
}

#menu a {
    font-size: 14px;
    color: White;
    font-weight: bold;
}

#menu a:hover {
    color: Yellow;
}

/* Spacer */
#spacer {   
    background-color: #8C8C8C;
}

/* Sidebar */
#sidebar {       
    margin-left: 100px;
    margin-right: 100px;
    padding-left: 10px;
    font-weight: bold;
    text-align: left;
    background: url(Images/leftborder.jpg) repeat-x left top;
    background-color: #C2C2C2;
}

#sidebar p {
    color: Black;
    font-weight: normal;
    font-size: 11px;
}

#sidebar a{
    color: Black;
    font-weight: normal;
    font-size: 11px;
}

/* Quick Links */
#quicklinks a{
    color: White;
    font-size: 12px;
    font-weight: bold;
    text-decoration:none
}

/* Content */
#content {
    margin-left: 200px;
    margin-top: 10px;
    padding-left: 10px;
    padding-right: 10px;
    background-color: #C2C2C2;
}

#content p {
    font-size: 12px;
}

#content a{
    color: Black;
    font-weight: bold;
}

/* Gallery */
#gallerylinks{
    border-color:Black; 
}

/* Footer Space */
#footerspace {
    background-color: #AB0000;   
}

/* Footer */
#footer {
    width: 891px;
    height: 70px;
    margin-left: 100px;
    margin-right: 100px;
    margin-top: 0px;
    margin-bottom: 0px;
    padding: 0 0 0 0;
    text-align: center;
    background-color: #C2C2C2;
    font-weight: bold;
    color: Black;
}

#footer a {
    font-weight: bold;
    color: Black;
}

#footer a:hover {
    color: Yellow;
}

最佳答案

如果您不希望宽度随分辨率/浏览器大小而变化,请在 CSS 中使用绝对宽度而不是百分比(860 像素而不是 90%)。

但是,如果它在其他人的浏览器中看起来不同,可能是因为他们的字体和字体大小不同。

关于html - 监控分辨率改变网站的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3039122/

相关文章:

Android 工具栏,居中文本布局问题

java - 无法在 android 中解析布局名称

javascript - 选择表中行具有样式显示标记的所有复选框

javascript - 如何将悬停替换为单击

html - 长 URL(超过设备宽度)的响应式解决方案

jquery - 当我选择一个 select 选项时触发 mouseleave 事件,尽管它不在该区域之外

html - css中方向对齐和文本对齐的区别

html - CSS 样式 - 调整浏览器窗口大小时元素向中心移动

html - 下载完整 CSS 后是否应该删除内联 CSS?

java - 如何保证 JPanel 适合 JFrame